/** * Sorts the specified range of the receiver into * ascending order, according to the <i>natural ordering</i> of its * elements. All elements in this range must implement the * <tt>Comparable</tt> interface. Furthermore, all elements in this range * must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt> * must not throw a <tt>ClassCastException</tt> for any elements * <tt>e1</tt> and <tt>e2</tt> in the array).<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 a the array to be sorted. */ public static void quickSort(Object[] a) { quickSort1(a, 0, a.length); } /**
/** * Sorts the specified range of the receiver into ascending order, according * to the <i>natural ordering</i> of its elements. All elements in this * range must implement the <tt>Comparable</tt> interface. Furthermore, all * elements in this range must be <i>mutually comparable</i> (that is, * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> * for any elements <tt>e1</tt> and <tt>e2</tt> in the array). * <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 a * the array to be sorted. */ public static void quickSort(Object[] a) { quickSort1(a, 0, a.length); }
/** * Sorts the specified range of the receiver into * ascending order, according to the <i>natural ordering</i> of its * elements. All elements in this range must implement the * <tt>Comparable</tt> interface. Furthermore, all elements in this range * must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt> * must not throw a <tt>ClassCastException</tt> for any elements * <tt>e1</tt> and <tt>e2</tt> in the array).<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 a the array to be sorted. */ public static void quickSort(Object[] a) { quickSort1(a, 0, a.length); } /**
/** * Sorts the specified range of the receiver into ascending order, according * to the <i>natural ordering</i> of its elements. All elements in this * range must implement the <tt>Comparable</tt> interface. Furthermore, all * elements in this range must be <i>mutually comparable</i> (that is, * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> * for any elements <tt>e1</tt> and <tt>e2</tt> in the array). * <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 a * the array to be sorted. */ public static void quickSort(Object[] a) { quickSort1(a, 0, a.length); }
/** * Sorts the specified range of the receiver into ascending order, according * to the <i>natural ordering</i> of its elements. All elements in this * range must implement the <tt>Comparable</tt> interface. Furthermore, all * elements in this range must be <i>mutually comparable</i> (that is, * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> * for any elements <tt>e1</tt> and <tt>e2</tt> in the array). * <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 a * the array to be sorted. */ public static void quickSort(Object[] a) { quickSort1(a, 0, a.length); }
/** * Sorts the specified array 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 a the array 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> * @see Comparator */ public static void quickSort(Object[] a, Comparator c) { quickSort1(a, 0, a.length, c); } /**
/** * Sorts the specified range of the receiver into * ascending order, according to the <i>natural ordering</i> of its * elements. All elements in this range must implement the * <tt>Comparable</tt> interface. Furthermore, all elements in this range * must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt> * must not throw a <tt>ClassCastException</tt> for any elements * <tt>e1</tt> and <tt>e2</tt> in the array).<p> * * @param a the array to be sorted. * @param fromIndex the index of the first element (inclusive) to be * sorted. * @param toIndex the index of the last element (exclusive) to be sorted. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or * <tt>toIndex > a.length</tt> */ public static void quickSort(Object[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); quickSort1(a, fromIndex, toIndex-fromIndex); } /**
/** * Sorts the specified range of the receiver into * ascending order, according to the <i>natural ordering</i> of its * elements. All elements in this range must implement the * <tt>Comparable</tt> interface. Furthermore, all elements in this range * must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt> * must not throw a <tt>ClassCastException</tt> for any elements * <tt>e1</tt> and <tt>e2</tt> in the array).<p> * * @param a the array to be sorted. * @param fromIndex the index of the first element (inclusive) to be * sorted. * @param toIndex the index of the last element (exclusive) to be sorted. * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or * <tt>toIndex > a.length</tt> */ public static void quickSort(Object[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); quickSort1(a, fromIndex, toIndex-fromIndex); } /**
/** * Sorts the specified range of the receiver into ascending order, according * to the <i>natural ordering</i> of its elements. All elements in this * range must implement the <tt>Comparable</tt> interface. Furthermore, all * elements in this range must be <i>mutually comparable</i> (that is, * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> * for any elements <tt>e1</tt> and <tt>e2</tt> in the array). * <p> * * @param a * the array to be sorted. * @param fromIndex * the index of the first element (inclusive) to be sorted. * @param toIndex * the index of the last element (exclusive) to be sorted. * @throws IllegalArgumentException * if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException * if <tt>fromIndex < 0</tt> or * <tt>toIndex > a.length</tt> */ public static void quickSort(Object[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); quickSort1(a, fromIndex, toIndex - fromIndex); }
/** * Sorts the specified range of the receiver into ascending order, according * to the <i>natural ordering</i> of its elements. All elements in this * range must implement the <tt>Comparable</tt> interface. Furthermore, all * elements in this range must be <i>mutually comparable</i> (that is, * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> * for any elements <tt>e1</tt> and <tt>e2</tt> in the array). * <p> * * @param a * the array to be sorted. * @param fromIndex * the index of the first element (inclusive) to be sorted. * @param toIndex * the index of the last element (exclusive) to be sorted. * @throws IllegalArgumentException * if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException * if <tt>fromIndex < 0</tt> or * <tt>toIndex > a.length</tt> */ public static void quickSort(Object[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); quickSort1(a, fromIndex, toIndex - fromIndex); }
/** * Sorts the specified range of the receiver into ascending order, according * to the <i>natural ordering</i> of its elements. All elements in this * range must implement the <tt>Comparable</tt> interface. Furthermore, all * elements in this range must be <i>mutually comparable</i> (that is, * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> * for any elements <tt>e1</tt> and <tt>e2</tt> in the array). * <p> * * @param a * the array to be sorted. * @param fromIndex * the index of the first element (inclusive) to be sorted. * @param toIndex * the index of the last element (exclusive) to be sorted. * @throws IllegalArgumentException * if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException * if <tt>fromIndex < 0</tt> or * <tt>toIndex > a.length</tt> */ public static void quickSort(Object[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); quickSort1(a, fromIndex, toIndex - fromIndex); }
quickSort1(a, fromIndex, toIndex-fromIndex, c);
/** * Multithreaded quicksort * * @param a * the array to be sorted. */ public static void parallelQuickSort(Object[] a) { if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, 0, a.length, ConcurrencyUtils.prevPow2(2 * ConcurrencyUtils .getNumberOfThreads())); } else { quickSort1(a, 0, a.length); } }
/** * Multithreaded quicksort * * @param a * the array to be sorted. */ public static void parallelQuickSort(Object[] a) { if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, 0, a.length, ConcurrencyUtils.prevPow2(2 * ConcurrencyUtils .getNumberOfThreads())); } else { quickSort1(a, 0, a.length); } }
/** * Multithreaded quicksort * * @param a * the array 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> * @see Comparator */ public static void parallelQuickSort(Object[] a, Comparator c) { if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, 0, a.length, c, ConcurrencyUtils.prevPow2(2 * ConcurrencyUtils .getNumberOfThreads())); } else { quickSort1(a, 0, a.length, c); } }
/** * Multithreaded quicksort * * @param a * the array 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> * @see Comparator */ public static void parallelQuickSort(Object[] a, Comparator c) { if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, 0, a.length, c, ConcurrencyUtils.prevPow2(2 * ConcurrencyUtils .getNumberOfThreads())); } else { quickSort1(a, 0, a.length, c); } }
/** * Multithreaded quicksort * * @param a * the array to be sorted. * @param fromIndex * the index of the first element (inclusive) to be sorted. * @param toIndex * the index of the last element (exclusive) to be sorted. * @throws IllegalArgumentException * if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException * if <tt>fromIndex < 0</tt> or * <tt>toIndex > a.length</tt> */ public static void parallelQuickSort(Object[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, fromIndex, toIndex - fromIndex, ConcurrencyUtils .prevPow2(2 * ConcurrencyUtils.getNumberOfThreads())); } else { quickSort1(a, fromIndex, toIndex - fromIndex); } }
/** * Multithreaded quicksort * * @param a * the array to be sorted. * @param fromIndex * the index of the first element (inclusive) to be sorted. * @param toIndex * the index of the last element (exclusive) to be sorted. * @throws IllegalArgumentException * if <tt>fromIndex > toIndex</tt> * @throws ArrayIndexOutOfBoundsException * if <tt>fromIndex < 0</tt> or * <tt>toIndex > a.length</tt> */ public static void parallelQuickSort(Object[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, fromIndex, toIndex - fromIndex, ConcurrencyUtils .prevPow2(2 * ConcurrencyUtils.getNumberOfThreads())); } else { quickSort1(a, fromIndex, toIndex - fromIndex); } }
/** * Multithreaded quicksort * * @param a * the array to be sorted. * @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 array. * @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> * @see Comparator */ public static void parallelQuickSort(byte[] a, int fromIndex, int toIndex, ByteComparator c) { rangeCheck(a.length, fromIndex, toIndex); if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, fromIndex, toIndex - fromIndex, c, ConcurrencyUtils .prevPow2(2 * ConcurrencyUtils.getNumberOfThreads())); } else { quickSort1(a, fromIndex, toIndex - fromIndex, c); } }
/** * Multithreaded quicksort * * @param a * the array to be sorted. * @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 array. * @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> * @see Comparator */ public static void parallelQuickSort(int[] a, int fromIndex, int toIndex, IntComparator c) { rangeCheck(a.length, fromIndex, toIndex); if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (a.length >= ConcurrencyUtils.getThreadsBeginN_1D())) { ParallelQuickSort.quickSort(a, fromIndex, toIndex - fromIndex, c, ConcurrencyUtils .prevPow2(2 * ConcurrencyUtils.getNumberOfThreads())); } else { quickSort1(a, fromIndex, toIndex - fromIndex, c); } }