[fpc-pascal] about dynamic array

José Mejuto joshyfun at gmail.com
Sat May 8 14:46:15 CEST 2010

Hello FPC-Pascal,

Saturday, May 8, 2010, 1:26:09 PM, you wrote:

>> 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).
VH> Implementing a dynamic array via a list implementation which
VH> is based on a dynamic array. Sure, that's faster.

Ok, let me known which operation is faster:

type ItemOfArray=record
  TheData: array [0..4095] of BYTE;

 TheArray: array of ItemArray;
 AnyItem: ItemOfArray;
 for j:=0 to 1000 do begin
 Now here add the code to remove element zero from the array and move
 down the upper elements.

  TheList: TList;
  AnyItem: ItemOfArray;
  p: Pointer;
  for j:=0 to 1000 do begin

  Remember that the user wants to have an array which could be
  extended and that allow fast insertion and remove. Of course it
  would be faster using an array of pointers, but TList will force the
  user to use an array of pointer, while a dynamic array will not as
  it can be used with the record type directly.

  IMHO the discussion was about how help the user to reach an
  objetive, not how to reach the objetive in the most efficient way
  but forcing the user to learn the inners of dynamic array. Remember
  the begins, "move (dynarray,...,...)" do not work "as expected".

  If you think that have a better proposal, write it...

  I can have some basic skills at some points in the pascal world, but
  I'm not stupid at such level to not known that a dynamic array (or
  similar) is being used in the background of TFPList.

Best regards,

More information about the fpc-pascal mailing list