Board index » delphi » Fastest way to append a variant array to a variant array

Fastest way to append a variant array to a variant array

//  This is my stab, but is there anything better?!?!
// assume that the Alllist is a two dimensional array with 13 by 25
// and I want to append another array of 13 by 25 to it (Appendlist)

var
 Alllist, Appendlist: Olevariant;
OldCount, X: integer;
begin
//  initialize the two arrays with something for testing

Alllist:=VararrayCreate([ 0, 13, 0, 25], varVariant);
Appendlist:=VararrayCreate([0, 13, 0, 25], varVariant);
for x:=0 to 13 do
  for y:=0 to 25 do
     Alllist[x, y]:=inttostr(x)+','+inttostr(y);
for x:=0 to 13 do
  for y:=0 to 25 do
     Appendlist[x, y]:=inttostr(x)+','+inttostr(y+25);

// now add the AppendList to the Alllist as fast as possible
//  This is what I need a faster way of doing!!!!

OldCount:=VarArrayHighBound(AllList, 2);
VarArrayRedim(AllList, OldCount+VarArrayHighBound(AppendList, 2));
for x:=1 to VarArrayHighBound(AppendList, 1) do
 for y:=1 to VarArrayHighBound(AppendList, 2) do
    AllList[x, y+OldCount]:=AppendList[x, y];

Showmessage(inttostr(VarArrayHighBound(Alllist, 2)));

end;

 

Re:Fastest way to append a variant array to a variant array


Hi,

Fine indeed.
You could just VarArrayLock your arrays before the loops.
And VarArrayUnlock then after.
Would go faster.

Bye.

Sent via Deja.com http://www.deja.com/
Before you buy.

Other Threads