/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Shorts.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(short[] 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(short[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); reverse(array, fromIndex, toIndex); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Shorts.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(short[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Shorts.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(short[] 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(short[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); 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(short[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); reverse(array, fromIndex, toIndex); }
private static void testReverse(short[] input, short[] expectedOutput) { input = Arrays.copyOf(input, input.length); Shorts.reverse(input); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testReverse( short[] input, int fromIndex, int toIndex, short[] expectedOutput) { input = Arrays.copyOf(input, input.length); Shorts.reverse(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Shorts.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(short[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Shorts.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(short[] 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(short[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); 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(short[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); Arrays.sort(array, fromIndex, toIndex); reverse(array, fromIndex, toIndex); }
private static void testReverse(short[] input, short[] expectedOutput) { input = Arrays.copyOf(input, input.length); Shorts.reverse(input); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testReverse( short[] input, int fromIndex, int toIndex, short[] expectedOutput) { input = Arrays.copyOf(input, input.length); Shorts.reverse(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }