/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Floats.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(float[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Floats.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(float[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Floats.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(float[] 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. * * <p>Note that this method uses the total order imposed by {@link Float#compare}, which treats * all NaN values as equal and 0.0 as greater than -0.0. * * @since 23.1 */ public static void sortDescending(float[] 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. * * <p>Note that this method uses the total order imposed by {@link Float#compare}, which treats * all NaN values as equal and 0.0 as greater than -0.0. * * @since 23.1 */ public static void sortDescending(float[] 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. * * <p>Note that this method uses the total order imposed by {@link Float#compare}, which treats * all NaN values as equal and 0.0 as greater than -0.0. * * @since 23.1 */ public static void sortDescending(float[] 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(float[] input, float[] expectedOutput) { input = Arrays.copyOf(input, input.length); Floats.reverse(input); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testReverse( float[] input, int fromIndex, int toIndex, float[] expectedOutput) { input = Arrays.copyOf(input, input.length); Floats.reverse(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Floats.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(float[] array) { checkNotNull(array); reverse(array, 0, array.length); }
/** * Reverses the elements of {@code array}. This is equivalent to {@code * Collections.reverse(Floats.asList(array))}, but is likely to be more efficient. * * @since 23.1 */ public static void reverse(float[] 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. * * <p>Note that this method uses the total order imposed by {@link Float#compare}, which treats * all NaN values as equal and 0.0 as greater than -0.0. * * @since 23.1 */ public static void sortDescending(float[] 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. * * <p>Note that this method uses the total order imposed by {@link Float#compare}, which treats * all NaN values as equal and 0.0 as greater than -0.0. * * @since 23.1 */ public static void sortDescending(float[] 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(float[] input, float[] expectedOutput) { input = Arrays.copyOf(input, input.length); Floats.reverse(input); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testReverse( float[] input, int fromIndex, int toIndex, float[] expectedOutput) { input = Arrays.copyOf(input, input.length); Floats.reverse(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }