summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-10-02 01:11:53 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-10-02 01:11:53 +0700
commit46504f16810e71e6291a2562148ef6d38a9e49da (patch)
tree4341f9166e5bccbe63b8c2acbf16819d52f2e223 /crypto/src
parentMissing file (diff)
downloadBouncyCastle.NET-ed25519-46504f16810e71e6291a2562148ef6d38a9e49da.tar.xz
Generic ReverseInPlace method
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/util/Arrays.cs31
1 files changed, 4 insertions, 27 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs

index 25114aca3..c2ba9c3e1 100644 --- a/crypto/src/util/Arrays.cs +++ b/crypto/src/util/Arrays.cs
@@ -901,36 +901,13 @@ namespace Org.BouncyCastle.Utilities return result; } - public static byte[] ReverseInPlace(byte[] a) + public static T[] ReverseInPlace<T>(T[] array) { - if (null == a) - return null; - - int p1 = 0, p2 = a.Length - 1; - while (p1 < p2) - { - byte t1 = a[p1], t2 = a[p2]; - a[p1++] = t2; - a[p2--] = t1; - } - - return a; - } - - public static int[] ReverseInPlace(int[] a) - { - if (null == a) + if (null == array) return null; - int p1 = 0, p2 = a.Length - 1; - while (p1 < p2) - { - int t1 = a[p1], t2 = a[p2]; - a[p1++] = t2; - a[p2--] = t1; - } - - return a; + Array.Reverse(array); + return array; } public static void Clear(byte[] data)