Skip to content

Commit 4c7eb54

Browse files
committed
Add new routine and method to Arrays category
Added new Reverse<T> method to TArrayUtils. Added new ReverseByteArray routine. Updated Arrays category to add meta data for new ReverseByteArray function and to update compile results for TArrayUtils.
1 parent 98cd73f commit 4c7eb54

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

collection/623.dat

+11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
const Count: Integer;
2222
const EqualityComparer: Generics.Defaults.TEqualityComparison<T>):
2323
Boolean; static;
24+
// Creates and returns a new array that is the reverse of the given array.
25+
class function Reverse<T>(const A: array of T): TArray<T>; static;
2426
end;
2527

2628
class function TArrayUtils.Equal<T>(const Left, Right: array of T;
@@ -60,6 +62,15 @@ begin
6062
Result := A[Pred(Length(A))];
6163
end;
6264

65+
class function TArrayUtils.Reverse<T>(const A: array of T): TArray<T>;
66+
var
67+
I: Integer;
68+
begin
69+
SetLength(Result, Length(A));
70+
for I := 0 to High(A) do
71+
Result[High(A)-I] := A[I];
72+
end;
73+
6374
class function TArrayUtils.SameStart<T>(const Left, Right: array of T;
6475
const Count: Integer;
6576
const EqualityComparer: Generics.Defaults.TEqualityComparison<T>): Boolean;

collection/656.dat

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ReverseByteArray(const A: array of Byte): TBytes;
2+
var
3+
I: Integer;
4+
begin
5+
SetLength(Result, Length(A));
6+
for I := 0 to High(A) do
7+
Result[High(A)-I] := A[I];
8+
end;

collection/arrays.ini

+14-8
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,19 @@ Delphi5=N
363363
Delphi6=N
364364
Delphi7=N
365365
Delphi2005Win32=N
366-
Delphi2006Win32=Y
366+
Delphi2006Win32=N
367367
Delphi2007=N
368-
Delphi2009Win32=Y
369-
Delphi2010=Y
370368
DelphiXE=Y
371-
DelphiXE2=Y
372-
DelphiXE3=Y
373-
DelphiXE4=Y
374-
Delphi10S=Y
375-
FPC=N
369+
Delphi12A=Y
370+
371+
[ReverseByteArray]
372+
Kind=routine
373+
DisplayName=ReverseByteArray
374+
DescEx="<p>Returns a copy of a given byte array with the order of the bytes reversed.</p>"
375+
Depends=TBytes
376+
TestInfo=advanced
377+
AdvancedTest.Level=unit-tests
378+
AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Arrays"
379+
Snip=656.dat
380+
DelphiXE=Y
381+
Delphi12A=Y

0 commit comments

Comments
 (0)