Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function Reverse: TVec; | Reverse vector elements. |
| └ indexed: function Reverse(Index: Integer; Len: Integer): TMtxVec; | ||
| 2 | function Reverse(const Vec: TMtxVec): TVec; | Reverse all Vec elements. |
| └ indexed: function Reverse(const Vec: TMtxVec; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec; |
Overload 1: function Reverse: TVec;
Reverse vector elements.
Result: stored in self (calling object), returns self for chaining
The method reverses vector elements by using the following equation:
This overload reverses all calling vector elements in-place.
var a: Vector;
begin
a.SetIt(False,[1,2,3,4]);
a.Reverse; // a = [4,3,2,1]
end;
var
a, expected: Vector;
begin
a := [1.0, 2.0, 3.0, 4.0];
a.Reverse;
expected := [4.0, 3.0, 2.0, 1.0];
if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
raise Exception.Create('Vector.Reverse: mismatch');
end;
Indexed: function Reverse(Index: Integer; Len: Integer): TMtxVec;
Reverses the calling object elements [Index]..[Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Index | Integer | start index |
| 2 | Len | Integer | element count |
Result: stored in self (calling object), returns self for chaining
An exception is raised if array borders are overrun.
Overload 2: function Reverse(const Vec: TMtxVec): TVec;
Reverse all Vec elements.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec | TMtxVec |
Result: stored in self (calling object), returns self for chaining
Store the result in the calling vector elements. The Vector.Length and Vector.Complex properties of the calling vector are set implicitly to match Vec vector.
var
a, x, expected: Vector;
begin
x := [1.0, 2.0, 3.0, 4.0];
a.Reverse(x);
expected := [4.0, 3.0, 2.0, 1.0];
if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
raise Exception.Create('Vector.Reverse: mismatch');
end;
Indexed: function Reverse(const Vec: TMtxVec; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
Reverse vector elements.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec | TMtxVec | |
| 2 | VecIndex | Integer | |
| 3 | Index | Integer | start index |
| 4 | Len | Integer | element count |
Result: stored in self (calling object), returns self for chaining
The method reverses Vec vector elements from [VecIndex].. [VecIndex+Len-1] and stores them in the calling vector from [Index]...[Index+Len-1] by using the following equation:
This overload reverses calling vector elements in-place.
var a: Vector;
begin
a.SetIt(False,[1,2,3,4]);
a.Reverse; // a = [4,3,2,1]
end;