Solved

Tlist and sort/find

Posted on 1998-07-28
11
476 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 2

Expert Comment

by:freter
ID: 1358821
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
ID: 1358822
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
ID: 1358823
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:kjteng
ID: 1358824
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
ID: 1358825
TStringList.Sorted := true
TStringList.IndexOf(const S: string)

-What's wrong with this?
0
 
LVL 2

Expert Comment

by:freter
ID: 1358826
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
ID: 1358827
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
ID: 1358828
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
ID: 1358829
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
ID: 1358830
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
ID: 1358831
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month7 days, left to enroll

622 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