As you have Delphi 2010 in your profile, generics should be not problem, are they?
Delphi-Quellcode:
TArrayUtil = class
public
class procedure Swap<T>(var Value1, Value2: T);
class procedure Reverse<T>(var Value: array of T);
end;
{ TArrayUtil }
class procedure TArrayUtil.Reverse<T>(var Value: array of T);
var
i: Integer;
begin
if Length(Value) > 0 then
for i := Low(Value) to High(Value) div 2 do
Swap<T>(Value[i], Value[High(Value) - i]);
end;
class procedure TArrayUtil.Swap<T>(var Value1, Value2: T);
var
Temp: T;
begin
Temp := Value1;
Value1 := Value2;
Value2 := Temp;
end;
Example usage:
Delphi-Quellcode:
var
Test: array of Integer;
i: Integer;
begin
SetLength(Test, 0);
for i := Low(Test) to High(Test) do
Test[i] := i;
TArrayUtil.Reverse<Integer>(Test);
for i := Low(Test) to High(Test) do
ShowMessage(IntToStr(Test[i]));
end;
// EDIT:
Of course it would be faster to swap directly in procedure Reverse.
// EDIT2:
Ok, translated to English and I did not see Delphi version 7 in the post. Then this won't work.