Solved

Tlist and sort/find

Posted on 1998-07-28
11
474 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Run video youtube webbrowse 10 86
PHP preg_replace code convert to Delphi 14 98
Using MMsystem To change audio input 1 39
Automatic field translation delphi 10.2 6 45
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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