/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Bytes.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(byte[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Bytes.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(byte[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Sorts the elements of {@code array} between {@code fromIndex} inclusive and {@code toIndex} * exclusive in descending order. * * @since 23.1 */ public static void sortDescending(byte[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); Bytes.reverse(array, fromIndex, toIndex); } }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Bytes.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(byte[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Sorts the elements of {@code array} between {@code fromIndex} inclusive and {@code toIndex} * exclusive in descending order. * * @since 23.1 */ public static void sortDescending(byte[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); Bytes.reverse(array, fromIndex, toIndex); } }
/** * Sorts the elements of {@code array} between {@code fromIndex} inclusive and {@code toIndex} * exclusive in descending order. * * @since 23.1 */ public static void sortDescending(byte[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); Bytes.reverse(array, fromIndex, toIndex); } }
private static void testReverse(byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); Bytes.reverse(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testReverse(byte[] input, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); Bytes.reverse(input); assertTrue(Arrays.equals(expectedOutput, input)); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Bytes.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(byte[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Bytes.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(byte[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Sorts the elements of {@code array} between {@code fromIndex} inclusive and {@code toIndex} * exclusive in descending order. * * @since 23.1 */ public static void sortDescending(byte[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); Bytes.reverse(array, fromIndex, toIndex); } }
/** * Sorts the elements of {@code array} between {@code fromIndex} inclusive and {@code toIndex} * exclusive in descending order. * * @since 23.1 */ public static void sortDescending(byte[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); Bytes.reverse(array, fromIndex, toIndex); } }
private static void testReverse(byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); Bytes.reverse(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testReverse(byte[] input, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); Bytes.reverse(input); assertTrue(Arrays.equals(expectedOutput, input)); }