I know this works:
type _AAAB = array of array of array of byte;
procedure fillArray(var arr: _AAAB; const v: byte); overload;
var
i, j, k: integer;
begin
for i := 0 to High(arr) do
begin
for j := 0 to High(arr[i]) do
begin
FillChar(arr[i][j][0], Length(arr[i][j]), v); // sizeof(byte)=1
end;
end;
end;
However, if the array is type of integer, 4 byte, the above will not work as expected.. What i want to do here is to speed up the following:
type _AAAI = array of array of array of integer;
procedure fillArray(var arr: _AAAI; const v: integer); overload;
var
i, j, k: integer;
begin
for i := 0 to High(arr) do
begin
for j := 0 to High(arr[i]) do
begin
for k := 0 to High(arr[i][j]) do
begin
arr[i][j][k] := v;
end;
end;
end;
end;
by replacing the inner loop... any advices? any faster method than FillChar? FillChar fills with byte, so it is not good here.
You can use a multibyte analogue to FillChar
, such as FillWord
or FillDWord
. You might have to write those functions yourself, if your environment doesn't already include them.