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

dmitry boyarintsev skalogryz.lists at gmail.com
Tue Apr 27 15:51:09 CEST 2010


On Tue, Apr 27, 2010 at 5:42 PM, Bihar Anwar <bihar_anwar at rocketmail.com> wrote:
> Just say, I have a dynamic array with size=5, and I want to delete elements from the index 0 to 2. Is there a trick (the fastest way) to delete those elements (0 to 2) without moving activities?

You won't do it faster than this:

var
 a: array of string;
 i : integer;

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

a[0]:=a[3];
a[1]:=a[4];
SetLength(a,2);

thanks,
dmitry



More information about the fpc-pascal mailing list