Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#12

Re: How to reverse array of any type?

  Alt 3. Dez 2012, 10:43
Delphi-Quellcode:
procedure ReverseArray(AData: Pointer; const ASize, ACount: Integer);
var
  Left, Right, Temp: Integer;
  P: PCardinal;
begin
  P := AData;

  Left := 0;
  Right := ACount;

  Result := Left < Right;

  if Result then
  begin
    while (Left < Right) do
    begin
      {Temp := AValues[Left];
      AValues[Left]  := AValues[Right];
      AValues[Right] := Temp;}
  // Don't know how to exchange with pointers :(
      //Move(P^, ..., ASize); // Don't know how if I don't know types ????????

      Inc(P);
      Inc(Left);
      Dec(Right);
    end;
  end;
end;
I don't know how replace part should works. Above is form reversing knowed type array.

Geändert von WojTec ( 3. Dez 2012 um 11:20 Uhr)
  Mit Zitat antworten Zitat