Copying multidimensional dynamic arrays

From: Andreas Winter (awin_at_wros.de)
Date: 01/23/04

  • Next message: Maarten Wiltink: "Re: Copying multidimensional dynamic arrays"
    Date: Fri, 23 Jan 2004 20:54:18 +0100
    
    

    Hi,

    I've got an 3-Dimensional dynamic Array with the following
    structure:

    Matrix : array of array of array of String; // Level,Y,X values

    Of course it would be initialised with SetLength. In my program
    I need to copy from one level to another the Y,X-Sub Array very
    often. I've build an nested for-loop wich works well but not as fast
    as I think.

    procedure TfrmMatrixr.CopyMatrix(fromM, toM : Integer);
    var
    x,y:Integer;
    begin
     for x:=1 to highx do
       for y:=1 to highy do
         matrix[toM,y,x]:=matrix[fromM,y,x];
    end;

    I would prefer to use

    Matrix[2]:=Copy[Matrix[0])

    wich won't work to speed up things. Or are there any other ideas
    I could use to improve the speed up this copy process??

    sincerely
    Andreas


  • Next message: Maarten Wiltink: "Re: Copying multidimensional dynamic arrays"

    Relevant Pages

    • Re: need to deallocate dynamic arrays (D4)
      ... SetLength(PretriggerBuffer, Pretrigger+1); ... To deallocate a dynamic array, assign nil to a variable that references the array or pass the variable to Finalize; either of these methods disposes of the array, provided there are no other references to it. ... I have other strings where I use SetLength, but they are temporary variables defined within procedures. ...
      (comp.lang.pascal.delphi.misc)
    • Re: dynamic Type declaration
      ... > SetLength ... > on a dynamic array? ... type tVariantArr = Array of Variant; ... ReadLn; ...
      (comp.lang.pascal.delphi.misc)
    • Re: dynamic Type declaration
      ... > SetLength ... > on a dynamic array? ... type tVariantArr = Array of Variant; ... ReadLn; ...
      (alt.comp.lang.borland-delphi)
    • Dynamic arrays
      ... I was thinking I could SetLengtha dynamic array of 700, ... will still loop through 700 right. ... I know I could do another setlength() for each time an index is added, ... but doing that 200 times in a loop would seem awfully wasteful. ...
      (comp.lang.pascal.delphi.misc)