File tree Expand file tree Collapse file tree 3 files changed +33
-8
lines changed Expand file tree Collapse file tree 3 files changed +33
-8
lines changed Original file line number Diff line number Diff line change 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
2628class function TArrayUtils.Equal<T>(const Left, Right: array of T;
6062 Result := A[Pred(Length(A))];
6163end;
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+
6374class function TArrayUtils.SameStart<T>(const Left, Right: array of T;
6475 const Count: Integer;
6576 const EqualityComparer: Generics.Defaults.TEqualityComparison<T>): Boolean;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change @@ -363,13 +363,19 @@ Delphi5=N
363363Delphi6 =N
364364Delphi7 =N
365365Delphi2005Win32 =N
366- Delphi2006Win32 =Y
366+ Delphi2006Win32 =N
367367Delphi2007 =N
368- Delphi2009Win32 =Y
369- Delphi2010 =Y
370368DelphiXE =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
You can’t perform that action at this time.
0 commit comments