Solved

Tlist and sort/find

Posted on 1998-07-28
11
467 Views
Last Modified: 2010-04-04
hi , anyone know about some components that take Tlist and have options of sort/find items init ?
0
Comment
Question by:asi
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 2

Expert Comment

by:freter
Comment Utility
asi:
You should derive your list class from TList:

>>>>>>



  TConfigData = class
  private
    FName: string;
    FTyp: string;
    FValue: string;
    FDescription: string;
    FSection: string;
  public
    constructor Create;
    function    Copy: TConfigData;
    property    Name: string read FName write FName;
    property    Typ: string read FTyp write FTyp;
    property    Value: string read FValue write FValue;
    property    Description: string read FDescription write FDescription;
    property    Section: string read FSection write FSection;
  end;

  TConfigDataList = class
  private
    FList: TList;
    FMachineName,
    FIPAddress,
    FSourceFile,
    FProductSection: string;
    function  GetCount: integer;
    function  GetData(const strName: string): TConfigData;
    procedure SetData(const strName: string; AData: TConfigData);
    function  GetDataByIndex(const iIndex: integer): TConfigData;
    procedure SetDataByIndex(const iIndex: integer; AData: TConfigData);
  public
    constructor Create;
    destructor  Destroy; override;

    function    Copy: TConfigDataList;

    procedure   Add(AConfigData: TConfigData);
    function    New: TConfigData;

    property    MachineName: string read FMachineName write FMachineName;
    property    IPAddress: string read FIPAddress write FIPAddress;
    property    SourceFile: string read FSourceFile write FSourceFile;
    property    ProductSection: string read FProductSection write FProductSection;
    property    Count: integer read GetCount;
    property    Data[const strName: string]: TConfigData read GetData write SetData;
    property    Items[const iIndex: integer]: TConfigData read GetDataByIndex write SetDataByIndex;
  end;

More infos? Full implementation? Just ask!
0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
hey asi.
mind 2 specify how find should work?
mayb i find a little chunk of time 2 buil a comp.
can't promise.

0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
oh-****.

sorry, frete. my page didn't load as fast as i had posted the answer. so i didn't c your comment in time. asi - ignore me.
bye -

Black Death.
0
 
LVL 2

Expert Comment

by:kjteng
Comment Utility
There is a freeware (with source) called TMkList (a subclass from tList) which I cannot remember where I downloaded from. It implements the following method
  QSort - for sorting the list;
  forEach(MyProc : TForEachProc) - to do myProc on each item in the list;
  firstThat( MyProc : TCompareProc) - to return the first item that will meet the condition set in myPoc
  LastThat(MyProc : TCompareProc) - to return the first item that will meet the condition set in myPoc

Let me have you email address if you are interested
0
 
LVL 3

Expert Comment

by:Matvey
Comment Utility
TStringList.Sorted := true
TStringList.IndexOf(const S: string)

-What's wrong with this?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:freter
Comment Utility
Matvey:
Sometimes the TStringlist class is a bit oversized, esp. if one wants to store simpley objects that have no "name". In former times (wow, sounds like I am a grandpa), I used to store my objects in TStringList as well, but nowadays I take the pain of deriving new list classes from TList. It simply gives you more performance and comes closer to the OOP paradigma.

Freter
0
 

Author Comment

by:asi
Comment Utility
to  kjteng

yes i"m intersted in that object
my e-mail is b_asi@inter.net.il
10x
Asi
0
 
LVL 3

Expert Comment

by:Matvey
Comment Utility
freter - on what do you sort in TList and on what do you search?
I think it's a set of pointer, right?

kjteng, bosism@netvision.net.il, if it's not too hard. I'll apriciate it a lot. -Thanks!
0
 

Author Comment

by:asi
Comment Utility
Tlist is a List of pointer usualy used from Objects;
this opbject need to have some property that need function (i gess) that has parameter object-items[x] and need to return a value
according to that Value the Tlistsort can serach/sort thet list
all the best
asi
b_asi@inter.net.il
0
 
LVL 2

Expert Comment

by:kjteng
Comment Utility
asi, matvery
I've sent the file
Let me know if you have problem receiving it

BTW both of you are from the same place? .il= Israel?
0
 
LVL 2

Accepted Solution

by:
kjteng earned 10 total points
Comment Utility
asi

Thanks for your mail.
Yes. I modified and used it for one of my program which is still under testing. So far so good.  The only thing I don't quite like is the "C flavour" of the code but then that is a matter of personal preference.


0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now