|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mahout.math.Sorting
public final class Sorting
| Method Summary | ||
|---|---|---|
static int |
binarySearchFromTo(byte[] array,
byte value,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static int |
binarySearchFromTo(char[] array,
char value,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static int |
binarySearchFromTo(double[] array,
double value,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static int |
binarySearchFromTo(float[] array,
float value,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static int |
binarySearchFromTo(int[] array,
int value,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static int |
binarySearchFromTo(long[] array,
long value,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static int |
binarySearchFromTo(short[] array,
short value,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static
|
binarySearchFromTo(T[] array,
T object,
int from,
int to)
Performs a binary search for the specified element in the specified ascending sorted array. |
|
static
|
binarySearchFromTo(T[] array,
T object,
int from,
int to,
Comparator<? super T> comparator)
Performs a binary search for the specified element in the specified ascending sorted array using the Comparator to compare elements. |
|
static void |
mergeSort(byte[] array,
int start,
int end)
Perform a merge sort on a range of a byte array, using numerical order. |
|
static void |
mergeSort(byte[] array,
int start,
int end,
ByteComparator comp)
Perform a merge sort on a range of a byte array using a specified ordering. |
|
static void |
mergeSort(char[] array,
int start,
int end)
Perform a merge sort on a range of a char array, using numerical order. |
|
static void |
mergeSort(char[] array,
int start,
int end,
CharComparator comp)
Perform a merge sort on a range of a char array using a specified ordering. |
|
static void |
mergeSort(double[] array,
int start,
int end)
Perform a merge sort on a range of a double array using a Double.compare as an ordering. |
|
static void |
mergeSort(double[] array,
int start,
int end,
DoubleComparator comp)
Perform a merge sort on a range of a double array using a specified ordering. |
|
static void |
mergeSort(float[] array,
int start,
int end)
Perform a merge sort on a range of a float array using Float.compare for an ordering. |
|
static void |
mergeSort(float[] array,
int start,
int end,
FloatComparator comp)
Perform a merge sort on a range of a float array using a specified ordering. |
|
static void |
mergeSort(int[] array,
int start,
int end)
|
|
static void |
mergeSort(int[] array,
int start,
int end,
IntComparator comp)
Perform a merge sort on a range of a int array using numerical order. |
|
static void |
mergeSort(int fromIndex,
int toIndex,
IntComparator c,
Swapper swapper)
Sorts the specified range of elements according to the order induced by the specified comparator. |
|
static void |
mergeSort(long[] array,
int start,
int end)
Perform a merge sort on a range of a long array using numerical order. |
|
static void |
mergeSort(long[] array,
int start,
int end,
LongComparator comp)
Perform a merge sort on a range of a long array using a specified ordering. |
|
static void |
mergeSort(short[] array,
int start,
int end)
Perform a merge sort on a range of a short array, using numerical order. |
|
static void |
mergeSort(short[] array,
int start,
int end,
ShortComparator comp)
|
|
static
|
mergeSort(T[] array,
int start,
int end)
Perform a merge sort of the specific range of an array of objects that implement Comparable. |
|
static
|
mergeSort(T[] array,
int start,
int end,
Comparator<T> comp)
Perform a merge sort on the specified range of an array. |
|
static void |
quickSort(byte[] array,
int start,
int end,
ByteComparator comp)
Sorts the specified range in the array in a specified order. |
|
static void |
quickSort(char[] array,
int start,
int end,
CharComparator comp)
Sorts the specified range in the array in a specified order. |
|
static void |
quickSort(double[] array,
int start,
int end,
DoubleComparator comp)
Sorts the specified range in the array in a specified order. |
|
static void |
quickSort(float[] array,
int start,
int end,
FloatComparator comp)
Sorts the specified range in the array in a specified order. |
|
static void |
quickSort(int[] array,
int start,
int end,
IntComparator comp)
Sorts the specified range in the array in a specified order. |
|
static void |
quickSort(int start,
int end,
IntComparator comp,
Swapper swap)
Sorts some external data with QuickSort. |
|
static void |
quickSort(long[] array,
int start,
int end,
LongComparator comp)
Sorts the specified range in the array in a specified order. |
|
static void |
quickSort(short[] array,
int start,
int end,
ShortComparator comp)
Sorts the specified range in the array in ascending numerical order. |
|
static
|
quickSort(T[] array,
int start,
int end)
Sort the specified range of an array of object that implement the Comparable interface. |
|
static
|
quickSort(T[] array,
int start,
int end,
Comparator<T> comp)
Sorts the specified range in the array in a specified order. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static int binarySearchFromTo(byte[] array,
byte value,
int from,
int to)
array - the sorted byte array to search.value - the byte element to find.from - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static int binarySearchFromTo(char[] array,
char value,
int from,
int to)
array - the sorted char array to search.value - the char element to find.from - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static int binarySearchFromTo(double[] array,
double value,
int from,
int to)
array - the sorted double array to search.value - the double element to find.from - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static int binarySearchFromTo(float[] array,
float value,
int from,
int to)
array - the sorted float array to search.value - the float element to find.from - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static int binarySearchFromTo(int[] array,
int value,
int from,
int to)
array - the sorted int array to search.value - the int element to find.from - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static int binarySearchFromTo(long[] array,
long value,
int from,
int to)
array - the sorted long array to search.value - the long element to find.from - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static <T extends Comparable<T>> int binarySearchFromTo(T[] array,
T object,
int from,
int to)
array - the sorted Object array to search.object - the Object element to findfrom - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static <T> int binarySearchFromTo(T[] array,
T object,
int from,
int to,
Comparator<? super T> comparator)
Comparator to compare elements.
Searching in an unsorted array has an undefined result. It's also undefined
which element is found if there are multiple occurrences of the same
element.
array - the sorted array to searchobject - the element to findfrom - the first index to sort, inclusive.to - the last index to sort, inclusive.comparator - the Comparator used to compare the elements.
public static int binarySearchFromTo(short[] array,
short value,
int from,
int to)
array - the sorted short array to search.value - the short element to find.from - the first index to sort, inclusive.to - the last index to sort, inclusive.
-index - 1 where the element would be inserted.
public static void quickSort(byte[] array,
int start,
int end,
ByteComparator comp)
array - the byte array to be sorted.start - the start index to sort.end - the last + 1 index to sort.comp - the comparison that determines the sort.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static void quickSort(int start,
int end,
IntComparator comp,
Swapper swap)
start - the start index to sort.end - the last + 1 index to sort.comp - the comparator.swap - an object that can exchange the positions of two items.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static void quickSort(char[] array,
int start,
int end,
CharComparator comp)
array - the char array to be sorted.start - the start index to sort.end - the last + 1 index to sort.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static void quickSort(double[] array,
int start,
int end,
DoubleComparator comp)
array - the double array to be sorted.start - the start index to sort.end - the last + 1 index to sort.comp - the comparison.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.Double.compareTo(Double)
public static void quickSort(float[] array,
int start,
int end,
FloatComparator comp)
array - the float array to be sorted.start - the start index to sort.end - the last + 1 index to sort.comp - the comparator.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static void quickSort(int[] array,
int start,
int end,
IntComparator comp)
array - the int array to be sorted.start - the start index to sort.end - the last + 1 index to sort.comp - the comparator.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static void quickSort(long[] array,
int start,
int end,
LongComparator comp)
array - the long array to be sorted.start - the start index to sort.end - the last + 1 index to sort.comp - the comparator.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static <T> void quickSort(T[] array,
int start,
int end,
Comparator<T> comp)
array - the array to be sorted.start - the start index to sort.end - the last + 1 index to sort.comp - the comparator.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static <T extends Comparable<? super T>> void quickSort(T[] array,
int start,
int end)
T - The type of object.array - the array.start - the first index.end - the last index (exclusive).
public static void quickSort(short[] array,
int start,
int end,
ShortComparator comp)
array - the short array to be sorted.start - the start index to sort.end - the last + 1 index to sort.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
public static <T> void mergeSort(T[] array,
int start,
int end,
Comparator<T> comp)
T - the type of object in the array.array - the array.start - first index.end - last index (exclusive).comp - comparator object.
public static <T extends Comparable<? super T>> void mergeSort(T[] array,
int start,
int end)
T - the type of the objects in the array.array - the array.start - the first index.end - the last index (exclusive).
public static void mergeSort(byte[] array,
int start,
int end)
array - the array.start - the first index.end - the last index (exclusive).
public static void mergeSort(byte[] array,
int start,
int end,
ByteComparator comp)
array - the array.start - the first index.end - the last index (exclusive).comp - the comparator object.
public static void mergeSort(char[] array,
int start,
int end)
array - the array.start - the first index.end - the last index (exclusive).
public static void mergeSort(char[] array,
int start,
int end,
CharComparator comp)
array - the array.start - the first index.end - the last index (exclusive).comp - the comparator object.
public static void mergeSort(short[] array,
int start,
int end)
array - the array.start - the first index.end - the last index (exclusive).
public static void mergeSort(short[] array,
int start,
int end,
ShortComparator comp)
public static void mergeSort(int[] array,
int start,
int end)
public static void mergeSort(int[] array,
int start,
int end,
IntComparator comp)
array - the array.start - the first index.end - the last index (exclusive).comp - the comparator object.
public static void mergeSort(long[] array,
int start,
int end)
array - the array.start - the first index.end - the last index (exclusive).
public static void mergeSort(long[] array,
int start,
int end,
LongComparator comp)
array - the array.start - the first index.end - the last index (exclusive).comp - the comparator object.
public static void mergeSort(float[] array,
int start,
int end)
array - the array.start - the first index.end - the last index (exclusive).
public static void mergeSort(float[] array,
int start,
int end,
FloatComparator comp)
array - the array.start - the first index.end - the last index (exclusive).comp - the comparator object.
public static void mergeSort(double[] array,
int start,
int end)
array - the array.start - the first index.end - the last index (exclusive).
public static void mergeSort(double[] array,
int start,
int end,
DoubleComparator comp)
array - the array.start - the first index.end - the last index (exclusive).comp - the comparator object.
public static void mergeSort(int fromIndex,
int toIndex,
IntComparator c,
Swapper swapper)
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.
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 generic data.swapper - an object that knows how to swap the elements at any two indexes (a,b).IntComparator,
Swapper
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||