AW: How to reverse array of any type?
2. Dez 2012, 19:18
By 'reverse' you mean: ABCD => DCBA?
Well, that's simple: All you need is the Address of the first element, the size of an element and the total number of elements (n), then you exchange elements 0 with n-1, 1 with n-2 and so on. To exchange an element you will need a temporary storage of ElementSize Bytes.
The signature of the function could be:
Procedure SwapArrayElements(aStartElement : Pointer; aElementSize, aElementCount : Integer);
|