Einzelnen Beitrag anzeigen

Dejan Vu
(Gast)

n/a Beiträge
 
#11

AW: Array SCHNELL auf Null setzen

  Alt 21. Okt 2014, 04:13
Also wie sieht denn nun der Code aus, um ein array of array of integer zu füllen?
Spontan:
Delphi-Quellcode:
Procedure ZeroDynamicMatrix (aMatrix : TMatrix; rows, cols : Integer);
var
  i : Integer;
  NumberOfBytesPerRow : Integer;

Begin
  setLength(aMatrix,rows);
  NumberOfBytesPerRow := cols*sizeof(aMatrix[0][0]); // sollte gehen, da compile time constant.
  for i:=0 to cols-1 do begin
    setLength(aMatrix[i], cols);
    FillChar(aMatrix[i][0], NumberOfBytesPerRow);
  end;
end;
Optimierungsvorschläge?
  Mit Zitat antworten Zitat