/** * Sorts some external data with QuickSort. * * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @param comp * the comparator. * @param swap an object that can exchange the positions of two items. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static void quickSort(int start, int end, IntComparator comp, Swapper swap) { checkBounds(end + 1, start, end); quickSort0(start, end, comp, swap); }
/** * Sorts the specified range in the array in a specified order. * * @param array * the {@code float} array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @param comp * the comparator. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static void quickSort(float[] array, int start, int end, FloatComparator comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Sorts the specified range in the array in a specified order. * * @param array * the array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @param comp * the comparator. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static <T> void quickSort(T[] array, int start, int end, Comparator<T> comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Sorts the specified range in the array in a specified order. * * @param array * the {@code char} array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static void quickSort(char[] array, int start, int end, CharComparator comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Sorts the specified range in the array in ascending numerical order. * * @param array * the {@code short} array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static void quickSort(short[] array, int start, int end, ShortComparator comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Sorts the specified range in the array in a specified order. * * @param array * the {@code int} array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @param comp * the comparator. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static void quickSort(int[] array, int start, int end, IntComparator comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Sorts the specified range in the array in a specified order. * * @param array * the {@code long} array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @param comp * the comparator. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static void quickSort(long[] array, int start, int end, LongComparator comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Perform a merge sort on the specified range of an array. * * @param <T> the type of object in the array. * @param array the array. * @param start first index. * @param end last index (exclusive). * @param comp comparator object. */ @SuppressWarnings("unchecked") // required to make the temp array work, afaict. public static <T> void mergeSort(T[] array, int start, int end, Comparator<T> comp) { checkBounds(array.length, start, end); int length = end - start; if (length <= 0) { return; } T[] out = (T[]) new Object[array.length]; System.arraycopy(array, start, out, start, length); mergeSort(out, array, start, end, comp); }
/** * Sorts the specified range in the array in a specified order. * * @param array * the {@code double} array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @param comp * the comparison. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. * @see Double#compareTo(Double) */ public static void quickSort(double[] array, int start, int end, DoubleComparator comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Sorts the specified range in the array in a specified order. * * @param array * the {@code byte} array to be sorted. * @param start * the start index to sort. * @param end * the last + 1 index to sort. * @param comp * the comparison that determines the sort. * @throws IllegalArgumentException * if {@code start > end}. * @throws ArrayIndexOutOfBoundsException * if {@code start < 0} or {@code end > array.length}. */ public static void quickSort(byte[] array, int start, int end, ByteComparator comp) { Preconditions.checkNotNull(array); checkBounds(array.length, start, end); quickSort0(start, end, array, comp); }
/** * Perform a merge sort on a range of a byte array using a specified ordering. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(byte[] array, int start, int end, ByteComparator comp) { checkBounds(array.length, start, end); byte[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
/** * Perform a merge sort on a range of a int array using numerical order. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(int[] array, int start, int end, IntComparator comp) { checkBounds(array.length, start, end); int[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
/** * Perform a merge sort on a range of a long array using a specified ordering. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(long[] array, int start, int end, LongComparator comp) { checkBounds(array.length, start, end); long[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
/** * Perform a merge sort on a range of a float array using a specified ordering. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(float[] array, int start, int end, FloatComparator comp) { checkBounds(array.length, start, end); float[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
/** * Perform a merge sort on a range of a double array using a specified ordering. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(double[] array, int start, int end, DoubleComparator comp) { checkBounds(array.length, start, end); double[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
/** * Perform a merge sort on a range of a char array using a specified ordering. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(char[] array, int start, int end, CharComparator comp) { checkBounds(array.length, start, end); char[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
public static void mergeSort(short[] array, int start, int end, ShortComparator comp) { checkBounds(array.length, start, end); short[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
public static void mergeSort(short[] array, int start, int end, ShortComparator comp) { checkBounds(array.length, start, end); short[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
/** * Perform a merge sort on a range of a int array using numerical order. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(int[] array, int start, int end, IntComparator comp) { checkBounds(array.length, start, end); int[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }
/** * Perform a merge sort on a range of a long array using a specified ordering. * @param array the array. * @param start the first index. * @param end the last index (exclusive). * @param comp the comparator object. */ public static void mergeSort(long[] array, int start, int end, LongComparator comp) { checkBounds(array.length, start, end); long[] out = Arrays.copyOf(array, array.length); mergeSort(out, array, start, end, comp); }