?
Solved

Tlist and sort/find

Posted on 1998-07-28
11
Medium Priority
?
477 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 40 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

719 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