|
Colt 1.2.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcern.colt.Sorting
Quicksorts, mergesorts and binary searches; complements java.util.Arrays. Contains, for example, the quicksort on Comparators and Comparables, which are still missing in java.util.Arrays of JDK 1.2. Also provides mergesorts for types not supported in java.util.Arrays, as well as a couple of other methods for primitive arrays. The quicksorts and mergesorts are the JDK 1.2 V1.26 algorithms, modified as necessary.
GenericSorting
,
Sorting
,
Arrays
Method Summary | |
static int |
binarySearchFromTo(byte[] list,
byte key,
int from,
int to)
Searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(char[] list,
char key,
int from,
int to)
Searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(double[] list,
double key,
int from,
int to)
Searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(float[] list,
float key,
int from,
int to)
Searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(int[] list,
int key,
int from,
int to)
Searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(int from,
int to,
IntComparator comp)
Generically searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(long[] list,
long key,
int from,
int to)
Searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(Object[] list,
Object key,
int from,
int to,
Comparator comparator)
Searches the list for the specified value using the binary search algorithm. |
static int |
binarySearchFromTo(short[] list,
short key,
int from,
int to)
Searches the list for the specified value using the binary search algorithm. |
static void |
mergeSort(byte[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
mergeSort(byte[] a,
int fromIndex,
int toIndex,
ByteComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
mergeSort(char[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
mergeSort(char[] a,
int fromIndex,
int toIndex,
CharComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
mergeSort(double[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
mergeSort(double[] a,
int fromIndex,
int toIndex,
DoubleComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
mergeSort(float[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
mergeSort(float[] a,
int fromIndex,
int toIndex,
FloatComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
mergeSort(int[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
mergeSort(int[] a,
int fromIndex,
int toIndex,
IntComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
mergeSort(long[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
mergeSort(long[] a,
int fromIndex,
int toIndex,
LongComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
mergeSort(short[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
mergeSort(short[] a,
int fromIndex,
int toIndex,
ShortComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
mergeSortInPlace(int[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of elements. |
static void |
quickSort(byte[] a,
int fromIndex,
int toIndex,
ByteComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
quickSort(char[] a,
int fromIndex,
int toIndex,
CharComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
quickSort(double[] a,
int fromIndex,
int toIndex,
DoubleComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
quickSort(float[] a,
int fromIndex,
int toIndex,
FloatComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
quickSort(int[] a,
int fromIndex,
int toIndex,
IntComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
quickSort(long[] a,
int fromIndex,
int toIndex,
LongComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
static void |
quickSort(Object[] a)
Sorts the specified range of the receiver into ascending order, according to the natural ordering of its elements. |
static void |
quickSort(Object[] a,
Comparator c)
Sorts the specified array according to the order induced by the specified comparator. |
static void |
quickSort(Object[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the receiver into ascending order, according to the natural ordering of its elements. |
static void |
quickSort(Object[] a,
int fromIndex,
int toIndex,
Comparator c)
Sorts the specified range of the specified array according to the order induced by the specified comparator. |
static void |
quickSort(short[] a,
int fromIndex,
int toIndex,
ShortComparator c)
Sorts the specified range of the specified array of elements according to the order induced by the specified comparator. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static int binarySearchFromTo(byte[] list, byte key, int from, int to)
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static int binarySearchFromTo(char[] list, char key, int from, int to)
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static int binarySearchFromTo(double[] list, double key, int from, int to)
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static int binarySearchFromTo(float[] list, float key, int from, int to)
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static int binarySearchFromTo(int[] list, int key, int from, int to)
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static int binarySearchFromTo(long[] list, long key, int from, int to)
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static int binarySearchFromTo(Object[] list, Object key, int from, int to, Comparator comparator)
If the list is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the list contains multiple elements equal to the specified key, there is no guarantee which instance will be found.
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.comparator
- the comparator by which the list is sorted.
ClassCastException
- if the list contains elements that are not
mutually comparable using the specified comparator.Arrays
,
Comparator
public static int binarySearchFromTo(short[] list, short key, int from, int to)
list
- the list to be searched.key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static int binarySearchFromTo(int from, int to, IntComparator comp)
from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.
Arrays
public static void mergeSort(byte[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void mergeSort(byte[] a, int fromIndex, int toIndex, ByteComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void mergeSort(char[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void mergeSort(char[] a, int fromIndex, int toIndex, CharComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void mergeSort(double[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void mergeSort(double[] a, int fromIndex, int toIndex, DoubleComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void mergeSort(float[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void mergeSort(float[] a, int fromIndex, int toIndex, FloatComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void mergeSort(int[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void mergeSort(int[] a, int fromIndex, int toIndex, IntComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void mergeSort(long[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void mergeSort(long[] a, int fromIndex, int toIndex, LongComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void mergeSort(short[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void mergeSort(short[] a, int fromIndex, int toIndex, ShortComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void mergeSortInPlace(int[] a, int fromIndex, int toIndex)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void quickSort(byte[] a, int fromIndex, int toIndex, ByteComparator c)
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.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(char[] a, int fromIndex, int toIndex, CharComparator c)
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.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(double[] a, int fromIndex, int toIndex, DoubleComparator c)
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.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(float[] a, int fromIndex, int toIndex, FloatComparator c)
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.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(int[] a, int fromIndex, int toIndex, IntComparator c)
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.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(long[] a, int fromIndex, int toIndex, LongComparator c)
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.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(Object[] a)
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.
a
- the array to be sorted.public static void quickSort(Object[] a, int fromIndex, int toIndex)
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthpublic static void quickSort(Object[] a, int fromIndex, int toIndex, Comparator c)
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.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the receiver.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(Object[] a, Comparator c)
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.
a
- the array to be sorted.c
- the comparator to determine the order of the receiver.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
public static void quickSort(short[] a, int fromIndex, int toIndex, ShortComparator c)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
a
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be
sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array.
ClassCastException
- if the array contains elements that are not
mutually comparable using the specified comparator.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 or
toIndex > a.lengthComparator
|
Colt 1.2.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |