/** * Sorts the specified range of elements 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(a, b)</tt> must not throw an * exception for any indexes <tt>a</tt> and * <tt>b</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 fromIndex the index of the first element (inclusive) to be sorted. * @param toIndex the index of the last element (exclusive) to be sorted. * @param c the comparator to determine the order of the generic data. * @param swapper an object that knows how to swap the elements at any two indexes (a,b). * * @see IntComparator * @see Swapper */ public static void quickSort(int fromIndex, int toIndex, IntComparator c, Swapper swapper) { quickSort1(fromIndex, toIndex-fromIndex, c, swapper); } /**
/** * Sorts the specified range of elements 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(a, b)</tt> must not throw an exception for any indexes * <tt>a</tt> and <tt>b</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 fromIndex * the index of the first element (inclusive) to be sorted. * @param toIndex * the index of the last element (exclusive) to be sorted. * @param c * the comparator to determine the order of the generic data. * @param swapper * an object that knows how to swap the elements at any two * indexes (a,b). * * @see IntComparator * @see Swapper */ public static void quickSort(int fromIndex, int toIndex, IntComparator c, Swapper swapper) { quickSort1(fromIndex, toIndex - fromIndex, c, swapper); }
/** * Sorts the specified range of elements 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(a, b)</tt> must not throw an * exception for any indexes <tt>a</tt> and * <tt>b</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 fromIndex the index of the first element (inclusive) to be sorted. * @param toIndex the index of the last element (exclusive) to be sorted. * @param c the comparator to determine the order of the generic data. * @param swapper an object that knows how to swap the elements at any two indexes (a,b). * * @see IntComparator * @see Swapper */ public static void quickSort(int fromIndex, int toIndex, IntComparator c, Swapper swapper) { quickSort1(fromIndex, toIndex-fromIndex, c, swapper); } /**
/** * Sorts the specified range of elements 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(a, b)</tt> must not throw an exception for any indexes * <tt>a</tt> and <tt>b</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 fromIndex * the index of the first element (inclusive) to be sorted. * @param toIndex * the index of the last element (exclusive) to be sorted. * @param c * the comparator to determine the order of the generic data. * @param swapper * an object that knows how to swap the elements at any two * indexes (a,b). * * @see IntComparator * @see Swapper */ public static void quickSort(int fromIndex, int toIndex, IntComparator c, Swapper swapper) { quickSort1(fromIndex, toIndex - fromIndex, c, swapper); }
quickSort1(fromIndex, toIndex - fromIndex, c, swapper);
quickSort1(off, s, comp, swapper); if ((s = d-c) > 1) quickSort1(n-s, s, comp, swapper);
quickSort1(off, s, comp, swapper); if ((s = d - c) > 1) quickSort1(n - s, s, comp, swapper);
quickSort1(off, s, comp, swapper); if ((s = d - c) > 1) quickSort1(n - s, s, comp, swapper);
quickSort1(off, s, comp, swapper); if ((s = d-c) > 1) quickSort1(n-s, s, comp, swapper);
quickSort1(off, s, comp, swapper); if ((s = d - c) > 1) quickSort1(n - s, s, comp, swapper);