[fpc-pascal] about dynamic array

Florian Klaempfl florian at freepascal.org
Thu May 6 20:58:33 CEST 2010

José Mejuto schrieb:
> 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.

A dyn. array of records requires no new/dispose as well as no type casts
as TList does.

More information about the fpc-pascal mailing list