On Fri, 28 May 2010, spir ☣ wrote:

On Fri, 28 May 2010 16:03:28 +0200 (CEST)
Michael Van Canneyt <mich...@freepascal.org> wrote:


TStrings provides an abstract interface. It allows you to associate an
object with each string in the list.

This means you can do a

   L.Strings[i]:=Key;
   L.Objects[i]:=MyObject;

Or, in 1 statement:

   L.AddObject(Key,MyObject);

And you can retrieve it with
   I:=L.IndexOf(MyKey);
   If (I=-1) then
    // no mykey in list
   else
    MyObject:=L.Objects[i];

Thank you very much, that's what I needed to understand.
If I get it right, using the Objects property is analog to what I intended to 
do with a TStringList for names // to a TFPList for values.

However, it does not actually implement this; it just provides a common
API for a string list with associated objects.

TStringList actually implements - in a simplistic way - the functionality
to store the strings, and the associated objects.

All right, now I get it. Just a point about doc: Some methods implemented in 
TStringList, but virtual in TString, are listed in the interface of TStringList 
at http://www.freepascal.org/docs-html/rtl/classes/tstringlist.html. But the 
ones dealings with associated objects aren't listed there (including the 
Objects property). This feature is also not mentionned in the description. So, 
I thought TStringList simply does not implement this functionality.
Another point: in the description of TList and TFPList is written that the 
notification system (not implemented on TFPList) is slows down some mechanisms. 
Is there a version of TStringList without this feature.
I need the simplest and most efficient version, because the type I'm now 
designing will be the elementary building block of a rather big system.

TStringList doesn't have the notification mechanism.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to