Solved

Tlist and sort/find

Posted on 1998-07-28
11
468 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filemaker 14 vs Delphi Embarcadero 7 186
Delphi XE2 application frozen on Windows 10 10 277
Delphi XE10, MySQL Query 4 127
Find and Replace Stream with 0s 8 57
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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