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