[lazarus] List indexed by string

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Dec 2 09:36:23 EST 2002


On Mon, 02 Dec 2002 15:17:50 +0100
"Daniel Mach" <dan.mach at centrum.cz> wrote:

> I need some list handling objects indexed by string.
> May I modifiy TObjectList or does it exist some better solution?
> I wish to make it compatible with Lazarus and Delphi.

There is a TStringHashList in lcl/stringhashlist.pas based on Martin
Waldenburgs hash list.

For example:
  TheList:=TStringHashList.Create;
  TheList['FirstItem']:=MyObject;
  AnotherObject:=TObject(TheList['FirstItem']);
  for i:=0 to List.Count-1 do
    with TheList.List[i] do
      writeln('Index=',i,' Key=',Key,' Data=',cardinal(Data));

Mattias






More information about the Lazarus mailing list