[fpc-pascal] Question about Deleting elements in Dynamic Array

Bihar Anwar bihar_anwar at rocketmail.com
Wed Apr 28 06:33:42 CEST 2010


I've tried to use Move() instead of Copy(). Any objection with the following code?

var
  a: array of string;

SetLength(a, 5);
a[0] := 'aa'; a[1] := 'bb'; a[2] := 'cc'; a[3] := 'dd'; a[4] := 'ee';

System.Move(a[3], a[0], 2 * SizeOf(string) );    // instead of  a := Copy(a, 3, 2);
SetLength(a, 2);



----- Original Message ----
From: dmitry boyarintsev <skalogryz.lists at gmail.com>
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Sent: Wed, April 28, 2010 10:31:09 AM
Subject: Re: [fpc-pascal] Question about Deleting elements in Dynamic Array

On Wed, Apr 28, 2010 at 7:24 AM, Bihar Anwar <bihar_anwar at rocketmail.com> wrote:
> Ok, I'll try to observe the compiled code using debugger and benchmark it if needed. BTW, what do you mean by allocating memory directly? Is there another way to allocate memory for dynamic array besides using SetLength()?

Copy() (from the existing dynamic array).
_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



      



More information about the fpc-pascal mailing list