Skip to content

Commit 764ee73

Browse files
committed
Add reverseInPlace variant
1 parent 0b86bcd commit 764ee73

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/src/main/java/org/bouncycastle/util/Arrays.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,17 @@ public static byte[] reverseInPlace(byte[] a)
10901090
return a;
10911091
}
10921092

1093+
public static void reverseInPlace(byte[] a, int aOff, int aLen)
1094+
{
1095+
int p1 = aOff, p2 = aOff + aLen - 1;
1096+
while (p1 < p2)
1097+
{
1098+
byte t1 = a[p1], t2 = a[p2];
1099+
a[p1++] = t2;
1100+
a[p2--] = t1;
1101+
}
1102+
}
1103+
10931104
public static int[] reverseInPlace(int[] a)
10941105
{
10951106
if (null == a)

0 commit comments

Comments
 (0)