Einzelnen Beitrag anzeigen

Benutzerbild von uligerhardt
uligerhardt

Registriert seit: 19. Aug 2004
Ort: Hof/Saale
1.735 Beiträge
 
Delphi 2007 Professional
 
#10

AW: Re: How to reverse array of any type?

  Alt 2. Dez 2012, 20:17
Ok, nice, nice, but how to access array elements if parameter is Pointer only? Array can be in any type.
With Furtbichler's routine signature you could have something like
Delphi-Quellcode:
procedure SwapArrayElements(aStartElement : Pointer; aElementSize, aElementCount : Integer);
var
  p: PByte;
begin
  p := AStartElement; // p points to first element
  Inc(p, aElementSize); // Now p points to second element
  Move(p^, ..., aElementSize); // Moves the element p points to
end;
(NB: These are only some building blocks of the routine, not the whole thing. )
Uli Gerhardt
  Mit Zitat antworten Zitat