[fpc-pascal] about dynamic array

José Mejuto joshyfun at gmail.com
Thu May 6 20:52:02 CEST 2010


Hello FPC-Pascal,

Thursday, May 6, 2010, 4:58:41 PM, you wrote:

>> c> TList wraps TFPList, which is based internally on an array. So access
>> c> is fast; insertion, deletion not.
>> 
>> But it is faster than inserting elements in a dynamic array (unless
>> reference counted ones) because it usually moves less amount of data
>> (4/8 bytes per element).
>> 
FK> Why do you think so? You can also create dyn. arrays of pointers.

I know, but I think this user is looking for a general purpose ordered
list accesible by index and TList more or less matches the request and
keep a more user friendly interface. Is quote "unless referenced
counted ones" because as referenced counted are pointers, a dyn array
of strings would be more or less as fast as a TList, well, a bit
faster in fact. If the user plans to use a record (which is my
suspect) with TList he must "new" and "dispose" the elements and he
will end up with a dyn array of pointers after all, which is a TList.

I know that sometimes I over simplify some things, but I think that
you'll agree with me that a deeper explain sometimes add fog to a
clear concept.

-- 
Best regards,
 José




More information about the fpc-pascal mailing list