/** * Sort the specified range of an array of object that implement the Comparable * interface. * @param <T> The type of object. * @param array the array. * @param start the first index. * @param end the last index (exclusive). */ public static <T extends Comparable<? super T>> void quickSort(T[] array, int start, int end) { quickSort(array, start, end, new ComparableAdaptor<T>()); }
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
/** * Sorts the receiver according to the order induced by the specified comparator. All elements in the range must be * <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> * * The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers * n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @param c the comparator to determine the order of the receiver. * @throws ClassCastException if the array contains elements that are not <i>mutually comparable</i> using * the specified comparator. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or <tt>toIndex > a.length</tt> * @throws IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || * to>=size())</tt>). */ public void quickSortFromTo(int from, int to, FloatComparator c) { int mySize = size(); checkRangeFromTo(from, to, mySize); float[] myElements = elements(); Sorting.quickSort(myElements, from, to + 1, c); elements(myElements); setSizeRaw(mySize); }
/** * Sorts the receiver according to the order induced by the specified comparator. All elements in the range must be * <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> * * The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers * n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @param c the comparator to determine the order of the receiver. * @throws ClassCastException if the array contains elements that are not <i>mutually comparable</i> using * the specified comparator. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or <tt>toIndex > a.length</tt> * @throws IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || * to>=size())</tt>). */ public void quickSortFromTo(int from, int to, LongComparator c) { int mySize = size(); checkRangeFromTo(from, to, mySize); long[] myElements = elements(); Sorting.quickSort(myElements, from, to + 1, c); elements(myElements); setSizeRaw(mySize); }
/** * Sorts the receiver according to the order induced by the specified comparator. All elements in the range must be * <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> * * The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers * n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @param c the comparator to determine the order of the receiver. * @throws ClassCastException if the array contains elements that are not <i>mutually comparable</i> using * the specified comparator. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or <tt>toIndex > a.length</tt> * @throws IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || * to>=size())</tt>). */ public void quickSortFromTo(int from, int to, DoubleComparator c) { int mySize = size(); checkRangeFromTo(from, to, mySize); double[] myElements = elements(); Sorting.quickSort(myElements, from, to + 1, c); elements(myElements); setSizeRaw(mySize); }
/** * Sorts the receiver according to the order induced by the specified comparator. All elements in the range must be * <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> * * The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers * n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @param c the comparator to determine the order of the receiver. * @throws ClassCastException if the array contains elements that are not <i>mutually comparable</i> using * the specified comparator. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or <tt>toIndex > a.length</tt> * @throws IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || * to>=size())</tt>). */ public void quickSortFromTo(int from, int to, ShortComparator c) { int mySize = size(); checkRangeFromTo(from, to, mySize); short[] myElements = elements(); Sorting.quickSort(myElements, from, to + 1, c); elements(myElements); setSizeRaw(mySize); }
/** * Sorts the receiver according to the order induced by the specified comparator. All elements in the range must be * <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> * * The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers * n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @param c the comparator to determine the order of the receiver. * @throws ClassCastException if the array contains elements that are not <i>mutually comparable</i> using * the specified comparator. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or <tt>toIndex > a.length</tt> * @throws IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || * to>=size())</tt>). */ public void quickSortFromTo(int from, int to, CharComparator c) { int mySize = size(); checkRangeFromTo(from, to, mySize); char[] myElements = elements(); Sorting.quickSort(myElements, from, to + 1, c); elements(myElements); setSizeRaw(mySize); }
/** * Sorts the receiver according to the order induced by the specified comparator. All elements in the range must be * <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> * * The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers * n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @param c the comparator to determine the order of the receiver. * @throws ClassCastException if the array contains elements that are not <i>mutually comparable</i> using * the specified comparator. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or <tt>toIndex > a.length</tt> * @throws IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || * to>=size())</tt>). */ public void quickSortFromTo(int from, int to, ByteComparator c) { int mySize = size(); checkRangeFromTo(from, to, mySize); byte[] myElements = elements(); Sorting.quickSort(myElements, from, to + 1, c); elements(myElements); setSizeRaw(mySize); }
/** * Sorts the receiver according to the order induced by the specified comparator. All elements in the range must be * <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> * * The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers * n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @param c the comparator to determine the order of the receiver. * @throws ClassCastException if the array contains elements that are not <i>mutually comparable</i> using * the specified comparator. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or <tt>toIndex > a.length</tt> * @throws IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || * to>=size())</tt>). */ public void quickSortFromTo(int from, int to, IntComparator c) { int mySize = size(); checkRangeFromTo(from, to, mySize); int[] myElements = elements(); Sorting.quickSort(myElements, from, to + 1, c); elements(myElements); setSizeRaw(mySize); }
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);
Sorting.quickSort(0, keyList.size(), comp, swapper);