Modifier and Type | Field and Description |
---|---|
static Comparator<int[]> |
COMPARATOR
Lexicographic order
|
static Comparator<Comparable[]> |
COMPARATOR_GENERIC
Lexicographic order
|
static Comparator<long[]> |
COMPARATOR_LONG
Lexicographic order
|
static Comparator<Object> |
HASH_COMPARATOR |
Modifier and Type | Method and Description |
---|---|
static int[] |
addAll(int[]... arrays) |
static int[] |
addAll(int[] array1,
int... array2) |
static long[] |
addAll(long[] array1,
long... array2) |
static <T> T[] |
addAll(T[] array1,
T... array2)
This code is taken from Apache Commons Lang ArrayUtils.
|
static char[] |
arrayOf(char val,
int len) |
static int[] |
arrayOf(int val,
int len) |
static long[] |
arrayOf(long val,
int len) |
static <T> T[] |
arrayOf(T val,
int len) |
static <T extends Comparable<? super T>> |
bijection(T[] from,
T[] to)
Creates a bijective mapping between two arrays and returns the resulting bijection as array.
|
static <T> int[] |
bijection(T[] from,
T[] to,
Comparator<? super T> comparator)
This method is similar to
bijection(Comparable[], Comparable[]) }, but uses specified comparator . |
static int |
binarySearch1(int[] a,
int key)
This is the same method to
Arrays.binarySearch(int[], int) . |
static int |
binarySearch1(int[] a,
int fromIndex,
int toIndex,
int key)
This is the same method to
Arrays.binarySearch(int[], int, int, int) . |
static int[] |
byte2int(byte[] a) |
static short[] |
byte2short(byte[] a) |
static int |
commutativeHashCode(int[] data)
Returns commutative hash code of the data
|
static int |
commutativeHashCode(int[] data,
int from,
int to)
Returns commutative hash code of the data
|
static <T> int |
commutativeHashCode(T[] data)
Returns commutative hash code of the data
|
static <T> int |
commutativeHashCode(T[] data,
int from,
int to)
Returns commutative hash code of the data
|
static int[][] |
deepClone(int[][] input) |
static Object[][] |
deepClone(Object[][] input) |
static int |
firstIndexOf(int element,
int[] array) |
static int |
firstIndexOf(Object element,
Object[] array) |
static int[] |
flatten(int[][] array) |
static BigInteger[] |
getSortedDistinct(BigInteger[] values)
Sort array & return array with removed repetitive values.
|
static int[] |
getSortedDistinct(int[] values)
Sort array & return array with removed repetitive values.
|
static long[] |
getSortedDistinct(long[] values)
Sort array & return array with removed repetitive values.
|
static int |
indexOfMax(int[] array) |
static int[] |
insert(int[] array,
int position,
int value) |
static int[] |
insert(int[] array,
int position,
int value,
int length) |
static long[] |
insert(long[] array,
int position,
long value) |
static <T> T[] |
insert(T[] array,
int position,
T value) |
static void |
insertionSort(int[] target,
int[] coSort)
Sorts the specified array of ints into ascending order using insertion sort algorithm and simultaneously permutes
the
coSort ints array in the same way as the target array. |
static void |
insertionSort(int[] target,
int fromIndex,
int toIndex,
int[] coSort)
Sorts the specified array of ints into ascending order using insertion sort algorithm and simultaneously permutes
the
coSort ints array in the same way as the target array. |
static void |
insertionSort(int[] target,
int fromIndex,
int toIndex,
long[] coSort)
Sorts the specified array of ints into ascending order using insertion sort algorithm and simultaneously permutes
the
coSort ints array in the same way as the target array. |
static void |
insertionSort(int[] target,
long[] coSort)
Sorts the specified array of ints into ascending order using insertion sort algorithm and simultaneously permutes
the
coSort longs array in the same way as the specified target array. |
static <T extends Comparable<T>> |
insertionSort(T[] target,
int[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements using insertion sort algorithm and simultaneously permutes the
coSort objects array in the same
way then specified target array. |
static <T extends Comparable<T>> |
insertionSort(T[] target,
int fromIndex,
int toIndex,
int[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements using insertion sort algorithm and simultaneously permutes the
coSort objects array in the same
way then specified target array. |
static <T extends Comparable<T>> |
insertionSort(T[] target,
int fromIndex,
int toIndex,
Object[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements using insertion sort algorithm and simultaneously permutes the
coSort objects array in the same
way then specified target array. |
static <T extends Comparable<T>> |
insertionSort(T[] target,
Object[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements using insertion sort algorithm and simultaneously permutes the
coSort objects array in the same
way then specified target array. |
static byte[] |
int2byte(int[] a) |
static short[] |
int2short(int[] a) |
static int[] |
intSetDifference(int[] main,
int[] delete)
Return the set difference B - A for int sets A and B.
Sets A and B must be represented as two sorted int arrays. Repetitive values in A or B not allowed. |
static int[] |
intSetUnion(int[] a,
int[] b)
Return the union B + A for integer sets A and B.
Sets A and B must be represented as two sorted integer arrays. Repetitive values in A or B not allowed. |
static int |
max(int[] array) |
static int[] |
max(int[] a,
int[] b) |
static int |
max(int[] array,
int from,
int to) |
static long |
max(long[] array) |
static int |
min(int[] array) |
static int[] |
min(int[] a,
int[] b) |
static int |
min(int[] array,
int from,
int to) |
static long |
min(long[] array) |
static int |
multiply(int[] array,
int from,
int to) |
static double |
multiplyToDouble(int[] array) |
static double |
multiplyToDouble(int[] array,
int from,
int to) |
static BigInteger[] |
negate(BigInteger[] arr) |
static int[] |
negate(int[] arr) |
static long[] |
negate(long[] arr) |
static int |
or(long[] array) |
static int |
or(long[] array,
int from) |
static int |
or(long[] array,
int from,
int to) |
static void |
quickSort(int[] target,
int[] coSort)
Sorts the specified target array of ints into ascending numerical order and simultaneously permutes the
coSort ints array in the same way as the target array. |
static void |
quickSort(int[] target,
int[] cosort,
IntComparator comparator)
Sorts the specified target array of ints according to
IntComparator and simultaneously permutes the
coSort Objects array in the same way as the target array. |
static void |
quickSort(int[] target,
IntComparator comparator)
Sorts the specified range of the specified target array of ints into order specified by
IntComparator
using quicksort. |
static void |
quickSort(int[] target,
int fromIndex,
int toIndex,
int[] coSort)
Sorts the specified range of the specified target array of ints into ascending numerical order and simultaneously
permutes the
coSort ints array in the same way as the target array. |
static void |
quickSort(int[] target,
int fromIndex,
int toIndex,
int[] cosort,
IntComparator comparator)
Sorts the specified range of the specified target array of ints according to
IntComparator and
simultaneously permutes the coSort Objects array in the same way as the target array. |
static void |
quickSort(int[] target,
int fromIndex,
int toIndex,
IntComparator comparator)
Sorts the specified range of the specified target array of ints into order specified by
IntComparator
using quicksort. |
static void |
quickSort(int[] target,
int fromIndex,
int toIndex,
long[] coSort)
Sorts the specified range of the specified target array of ints into ascending numerical order and simultaneously
permutes the
coSort longs array in the same way as the target array. |
static void |
quickSort(int[] target,
int fromIndex,
int toIndex,
Object[] coSort)
Sorts the specified range of the specified target array of ints into ascending numerical order and simultaneously
permutes the
coSort Objects array in the same way as the target array. |
static void |
quickSort(int[] target,
long[] coSort)
Sorts the specified target array of ints into ascending numerical order and simultaneously permutes the
coSort longs array in the same way as the target array. |
static void |
quickSort(int[] target,
Object[] coSort)
Sorts the specified target array of ints into ascending numerical order and simultaneously permutes the
coSort Objects array in the same way as the target array. |
static void |
quickSort(long[] target,
int fromIndex,
int toIndex,
long[] coSort)
Sorts the specified range of the specified target array of ints into ascending numerical order and simultaneously
permutes the
coSort longs array in the same way as the target array. |
static void |
quickSort(long[] target,
long[] coSort)
Sorts the specified target array of ints into ascending numerical order and simultaneously permutes the
coSort longs array in the same way as the target array. |
static void |
quickSort(short[] target,
int[] coSort)
Sorts the specified target array of shorts into ascending numerical order and simultaneously permutes the
coSort ints array in the same way as the target array. |
static void |
quickSort(short[] target,
int fromIndex,
int toIndex,
int[] coSort)
Sorts the specified range of the specified target array of ints into ascending numerical order and simultaneously
permutes the
coSort ints array in the same way as the target array. |
static <T extends Comparable<T>> |
quickSort(T[] target,
int[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements and simultaneously permutes the
coSort objects array in the same way then specified target
array. |
static <T extends Comparable<T>> |
quickSort(T[] target,
int fromIndex,
int toIndex,
int[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements and simultaneously permutes the
coSort objects array in the same way then specified target
array. |
static <T extends Comparable<T>> |
quickSort(T[] target,
int fromIndex,
int toIndex,
Object[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements and simultaneously permutes the
coSort objects array in the same way then specified target
array. |
static <T extends Comparable<T>> |
quickSort(T[] target,
Object[] coSort)
Sorts the specified target array of objects into ascending order, according to the natural ordering of its
elements and simultaneously permutes the
coSort objects array in the same way then specified target
array. |
static void |
quickSort1(int[] target,
int fromIndex,
int length,
int[] coSort)
This method is the same as
quickSort(int[], int, int, int[]) , but without range checking and toIndex ->
length (see params). |
static void |
quickSort1(int[] target,
int fromIndex,
int length,
IntComparator comparator)
Sorts the specified range of the specified target array of ints into order specified by
IntComparator
using quicksort. |
static void |
quickSort1(int[] target,
int fromIndex,
int length,
long[] coSort)
This method is the same as
) , but without range checking. |
static void |
quickSort1(int[] target,
int fromIndex,
int length,
Object[] coSort)
This method is the same as
) , but without range checking. |
static void |
quickSort1(long[] target,
int fromIndex,
int length,
long[] coSort)
This method is the same as
) , but without range checking. |
static void |
quickSort1(short[] target,
int fromIndex,
int length,
int[] coSort)
This method is the same as
quickSort(int[], int, int, int[]) , but without range checking and toIndex ->
length (see params). |
static <T extends Comparable<T>> |
quickSort1(T[] target,
int fromIndex,
int length,
int[] coSort)
This method is the same as
quickSort(Comparable[], int, int, Object[]) , but without range checking. |
static <T extends Comparable<T>> |
quickSort1(T[] target,
int fromIndex,
int length,
Object[] coSort)
This method is the same as
quickSort(Comparable[], int, int, Object[]) , but without range checking. |
static int[] |
quickSortP(int[] target)
Sorts the specified array and returns the resulting permutation
|
static int[] |
quickSortP(short[] target) |
static int[] |
remove(int[] array,
int i) |
static int[] |
remove(int[] array,
int[] positions)
Removes elements at specified
positions in specified array . |
static long[] |
remove(long[] array,
int i) |
static long[] |
remove(long[] array,
int[] positions)
Removes elements at specified
positions in specified array . |
static <T> T[] |
remove(T[] array,
int i) |
static <T> T[] |
remove(T[] array,
int[] positions)
Removes elements at specified
positions in specified array . |
static void |
reverse(int[] array) |
static void |
reverse(int[] array,
int from,
int to) |
static void |
reverse(long[] array) |
static void |
reverse(long[] array,
int from,
int to) |
static <T> void |
reverse(T[] array) |
static <T> void |
reverse(T[] array,
int from,
int to) |
static int[] |
select(int[] array,
int[] positions)
Selects elements from specified
array at specified positions . |
static <T> T[] |
select(T[] array,
int[] positions)
Selects elements from specified
array at specified positions . |
static int[] |
sequence(int size) |
static int[] |
sequence(int from,
int to) |
static int[] |
short2int(short[] a) |
static void |
shuffle(int[] array,
org.apache.commons.math3.random.RandomGenerator rnd) |
static void |
stableSort(int[] target,
int[] cosort)
Sorts the specified array of ints into ascending order using stable sort algorithm and simultaneously permutes
the
coSort ints array in the same way as the target array. |
static int[] |
subtract(int[] a,
int[] b) |
static int |
sum(int[] array) |
static int |
sum(int[] array,
int from) |
static int[] |
sum(int[] a,
int[] b) |
static int |
sum(int[] array,
int from,
int to) |
static double |
sumToDouble(int[] array) |
static double |
sumToDouble(int[] array,
int from,
int to) |
static void |
swap(int[] x,
int a,
int b)
Swaps x[a] with x[b].
|
static void |
swap(long[] x,
int a,
int b)
Swaps x[a] with x[b].
|
static void |
swap(Object[] x,
int a,
int b)
Swaps x[a] with x[b].
|
static void |
timSort(int[] target,
int[] coSort)
Sorts the specified array of ints into ascending order using TimSort algorithm and simultaneously permutes the
coSort ints array in the same way as the target array. |
static int[] |
toArray(Set<Integer> set)
Converts
Set<Integer> to int[] |
static String |
toString(long[] a,
int from,
int to) |
static <T> String |
toString(T[] a,
int from,
int to) |
static <T> String |
toString(T[] a,
int from,
int to,
Function<T,String> stringer) |
public static final Comparator<Object> HASH_COMPARATOR
public static final Comparator<int[]> COMPARATOR
public static final Comparator<long[]> COMPARATOR_LONG
public static final Comparator<Comparable[]> COMPARATOR_GENERIC
public static int[] flatten(int[][] array)
public static int[] arrayOf(int val, int len)
public static long[] arrayOf(long val, int len)
public static char[] arrayOf(char val, int len)
public static <T> T[] arrayOf(T val, int len)
public static int[] negate(int[] arr)
public static long[] negate(long[] arr)
public static BigInteger[] negate(BigInteger[] arr)
public static String toString(long[] a, int from, int to)
public static <T> String toString(T[] a, int from, int to)
public static void shuffle(int[] array, org.apache.commons.math3.random.RandomGenerator rnd)
public static int[] getSortedDistinct(int[] values)
values
- input array (this method will quickSort this array)public static BigInteger[] getSortedDistinct(BigInteger[] values)
values
- input array (this method will quickSort this array)public static long[] getSortedDistinct(long[] values)
values
- input array (this method will quickSort this array)public static int[] intSetDifference(int[] main, int[] delete)
main
- sorted array of distinct values (set B)delete
- sorted array of distinct values (set A)public static int[] intSetUnion(int[] a, int[] b)
a
- sorted array of distinct values. (set A)b
- sorted array of distinct values. (set B)public static int[] insert(int[] array, int position, int value)
public static int[] insert(int[] array, int position, int value, int length)
public static long[] insert(long[] array, int position, long value)
public static <T> T[] insert(T[] array, int position, T value)
public static void reverse(int[] array, int from, int to)
public static void reverse(long[] array, int from, int to)
public static <T> void reverse(T[] array, int from, int to)
public static <T> void reverse(T[] array)
public static void reverse(int[] array)
public static void reverse(long[] array)
public static int[] short2int(short[] a)
public static short[] int2short(int[] a)
public static int[] byte2int(byte[] a)
public static short[] byte2short(byte[] a)
public static byte[] int2byte(int[] a)
public static int max(int[] array)
public static long max(long[] array)
public static int max(int[] array, int from, int to)
public static int[] max(int[] a, int[] b)
public static int min(int[] array)
public static long min(long[] array)
public static int min(int[] array, int from, int to)
public static int[] min(int[] a, int[] b)
public static int firstIndexOf(int element, int[] array)
public static int indexOfMax(int[] array)
public static int[] sequence(int size)
public static int[] sequence(int from, int to)
public static int[][] deepClone(int[][] input)
public static int sum(int[] array)
public static int[] sum(int[] a, int[] b)
public static int[] subtract(int[] a, int[] b)
public static int sum(int[] array, int from)
public static int sum(int[] array, int from, int to)
public static int multiply(int[] array, int from, int to)
public static double multiplyToDouble(int[] array, int from, int to)
public static double multiplyToDouble(int[] array)
public static double sumToDouble(int[] array, int from, int to)
public static double sumToDouble(int[] array)
public static int or(long[] array)
public static int or(long[] array, int from)
public static int or(long[] array, int from, int to)
public static <T> int[] bijection(T[] from, T[] to, Comparator<? super T> comparator)
bijection(Comparable[], Comparable[])
}, but uses specified comparator
.from
- from arrayto
- to arraycomparator
- comparatorfrom
-array to to
-array and null
if no mapping existpublic static <T extends Comparable<? super T>> int[] bijection(T[] from, T[] to)
Example:
Integer from[] = {1,2,1,4}; Integer to[] = {2,4,1,1}; int[] bijection = bijection(from,to);
The resulting bijection will be [2, 0, 3, 1]
from
- from arrayto
- to arrayfrom
-array to to
-array and null
if no mapping existpublic static int[] addAll(int[] array1, int... array2)
public static long[] addAll(long[] array1, long... array2)
public static int[] addAll(int[]... arrays)
public static int[] remove(int[] array, int i)
public static long[] remove(long[] array, int i)
public static <T> T[] remove(T[] array, int i)
@SafeVarargs public static <T> T[] addAll(T[] array1, T... array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1
followed by all of the elements
array2
. When an array is returned, it is always a new array.
ArrayUtils.addAll(null, null) = null ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = [] ArrayUtils.addAll([null], [null]) = [null, null] ArrayUtils.addAll(["a", "b", "c"], ["1", "2", "3"]) = ["a", "b", "c", "1", "2", "3"]
T
- the component type of the arrayarray1
- the first array whose elements are added to the new array, may be null
array2
- the second array whose elements are added to the new array, may be null
null
if both arrays are null
. The type of the new array is the type of the
first array, unless the first array is null, in which case the type is the same as the second array.IllegalArgumentException
- if the array types are incompatiblepublic static <T> T[] remove(T[] array, int[] positions)
positions
in specified array
. This method preserve the relative
order of elements in specified array
.T
- generic typearray
- array of elementspositions
- positions of elements that should be removedArrayIndexOutOfBoundsException
- if some position larger then array lengthpublic static int[] remove(int[] array, int[] positions)
positions
in specified array
. This method preserve the relative
order of elements in specified array
.array
- array of elementspositions
- positions of elements that should be removedArrayIndexOutOfBoundsException
- if some position larger then array lengthpublic static long[] remove(long[] array, int[] positions)
positions
in specified array
. This method preserve the relative
order of elements in specified array
.array
- array of elementspositions
- positions of elements that should be removedArrayIndexOutOfBoundsException
- if some position larger then array lengthpublic static <T> T[] select(T[] array, int[] positions)
array
at specified positions
. The resulting array preserves the
relative order of elements in specified array
.T
- generic typearray
- array of elementspositions
- of elements that should be picked outpublic static int[] select(int[] array, int[] positions)
array
at specified positions
. The resulting array preserves the
relative order of elements in specified array
.array
- array of elementspositions
- of elements that should be picked outpublic static int binarySearch1(int[] a, int key)
Arrays.binarySearch(int[], int)
. The differs is in the returned value. If key
not found, this method returns the position of the first element, witch is closest to key (i.e. if
Arrays.binarySearch returns -low-1
, this method returns low
).a
- the array to be searchedkey
- the value to be searched forpublic static int binarySearch1(int[] a, int fromIndex, int toIndex, int key)
Arrays.binarySearch(int[], int, int, int)
. The differs is in the returned
value. If key not found, this method returns the position of the first element, witch is closest to key (i.e. if
Arrays.binarySearch returns -low-1
, this method returns low
).a
- the array to be searchedkey
- the value to be searched forfromIndex
- the index of the first element (inclusive) to be searchedtoIndex
- the index of the last element (exclusive) to be searchedpublic static <T> int commutativeHashCode(T[] data)
data
- arraypublic static <T> int commutativeHashCode(T[] data, int from, int to)
data
- arraypublic static int commutativeHashCode(int[] data)
data
- arraypublic static int commutativeHashCode(int[] data, int from, int to)
data
- arraypublic static void insertionSort(int[] target, int[] coSort)
coSort
ints array in the same way as the target array. This sort guarantee O(n^2) performance in the
worst case and O(n) in the best case (nearly sorted input). This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static void insertionSort(int[] target, int fromIndex, int toIndex, int[] coSort)
coSort
ints array in the same way as the target array. This sort guarantee O(n^2) performance in the
worst case and O(n) in the best case (nearly sorted input). The range to be sorted extends from index
fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the range
to be sorted is empty.) This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static void insertionSort(int[] target, long[] coSort)
coSort
longs array in the same way as the specified target array. This sort guarantee O(n^2)
performance in the worst case and O(n) in the best case (nearly sorted input). This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static void insertionSort(int[] target, int fromIndex, int toIndex, long[] coSort)
coSort
ints array in the same way as the target array. This sort guarantee O(n^2) performance in the
worst case and O(n) in the best case (nearly sorted input). The range to be sorted extends from index
fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the range
to be sorted is empty.) This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the specified target array, during sorting
procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static <T extends Comparable<T>> void insertionSort(T[] target, Object[] coSort)
coSort
objects array in the same
way then specified target array. This sort guarantee O(n^2) performance in the worst case and O(n) in the best
case (nearly sorted input). This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static <T extends Comparable<T>> void insertionSort(T[] target, int fromIndex, int toIndex, Object[] coSort)
coSort
objects array in the same
way then specified target array. This sort guarantee O(n^2) performance in the worst case and O(n) in the best
case (nearly sorted input). The range to be sorted extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the range to be sorted is empty.) This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static <T extends Comparable<T>> void insertionSort(T[] target, int[] coSort)
coSort
objects array in the same
way then specified target array. This sort guarantee O(n^2) performance in the worst case and O(n) in the best
case (nearly sorted input). This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static <T extends Comparable<T>> void insertionSort(T[] target, int fromIndex, int toIndex, int[] coSort)
coSort
objects array in the same
way then specified target array. This sort guarantee O(n^2) performance in the worst case and O(n) in the best
case (nearly sorted input). The range to be sorted extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the range to be sorted is empty.) This sort is the best choice for small arrays with elements number < 100.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort; adaptive: performance adapts to the initial order of elements and in-place: requires constant amount of additional space.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static void timSort(int[] target, int[] coSort)
coSort
ints array in the same way as the target array. NOTE: using of this method is very good for large arrays with more then 100 elements, in other case using of insertion sort is highly recommended.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The code was taken from Arrays.sort(java.lang.Object[])
and adapted for integers. For more
information look there.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureClassCastException
- if the array contains elements that are not mutually comparable (for example,
strings and integers)Arrays.sort(java.lang.Object[])
public static void stableSort(int[] target, int[] cosort)
coSort
ints array in the same way as the target array. If length of specified array is less than 100
- insertion sort algorithm performed, otherwise - TimSort. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
target
- the array to be sortedcosort
- the array which will be permuted in the same way as the target array during sorting procedureClassCastException
- if the array contains elements that are not mutually comparable (for
example, strings and integers)IllegalArgumentException
- if coSort length less then target length.IllegalArgumentException
- if target == coSort (as references).insertionSort(int[], int[])
,
timSort(int[], int[])
public static int[] quickSortP(int[] target)
target
- int arraypublic static void quickSort(int[] target, int[] coSort)
coSort
ints array in the same way as the target array. The code was taken from the jdk6 Arrays class.
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.
NOTE: remember this is unstable sort algorithm, so additional combinatorics of the coSort
array can
be perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like
an insertion sort or Tim sort.
NOTE: The method throws IllegalArgumentException
if
target == coSort
, because in this case no sorting will be perfomed.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.IllegalArgumentException
- if target == coSort (as references).public static void quickSort(int[] target, int fromIndex, int toIndex, int[] coSort)
coSort
ints array in the same way as the target array. The range to be sorted extends from
index fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the
range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE:
remember this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
NOTE: The method throws IllegalArgumentException
if target == coSort
, because in this case no sorting will be perfomed.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthIllegalArgumentException
- if target == coSort (as references).public static void quickSort1(int[] target, int fromIndex, int length, int[] coSort)
quickSort(int[], int, int, int[])
, but without range checking and toIndex ->
length (see params). Throws IllegalArgumentException
if target == coSort
, because in this case no
sorting will be perfomed . NOTE: this is unstable sort algorithm, so additional combinatorics of the
coSort
array can be perfomed. Use this method only if you are sure, in what you are doing. If not - use
stable sort methods like an insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.coSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if target == coSort (as references).public static void swap(int[] x, int a, int b)
public static void quickSort(long[] target, long[] coSort)
coSort
longs array in the same way as the target array. The code was taken from the jdk6 Arrays class.
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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static void quickSort(long[] target, int fromIndex, int toIndex, long[] coSort)
coSort
longs array in the same way as the target array. The range to be sorted extends from
index fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the
range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
performed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static void quickSort1(long[] target, int fromIndex, int length, long[] coSort)
)
, but without range checking.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
performed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.coSort
- the array which will be permuted in the same way as the target array, during sorting procedurepublic static void quickSort(int[] target, long[] coSort)
coSort
longs array in the same way as the target array. The code was taken from the jdk6 Arrays class.
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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static void quickSort(int[] target, int fromIndex, int toIndex, long[] coSort)
coSort
longs array in the same way as the target array. The range to be sorted extends from
index fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the
range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
performed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static void quickSort1(int[] target, int fromIndex, int length, long[] coSort)
)
, but without range checking.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
performed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.coSort
- the array which will be permuted in the same way as the target array, during sorting procedurepublic static void swap(long[] x, int a, int b)
public static <T extends Comparable<T>> void quickSort(T[] target, Object[] coSort)
coSort
objects array in the same way then specified target
array. The code was taken from the jdk6 Arrays class. 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. NOTE: this is unstable sort
algorithm, so additional combinatorics of the coSort
array can be perfomed. Use this method only if you
are sure, in what you are doing. If not - use stable sort methods like an insertion sort or Tim sort.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if fromIndex > toIndexIllegalArgumentException
- if coSort length less then target length.IllegalArgumentException
- if target == coSort (as references).public static <T extends Comparable<T>> void quickSort(T[] target, int fromIndex, int toIndex, Object[] coSort)
coSort
objects array in the same way then specified target
array. The range to be sorted extends from index fromIndex, inclusive, to index toIndex,
exclusive. (If fromIndex==toIndex, the range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the
coSort
array can be perfomed. Use this method only if you are sure, in what you are doing. If not - use
stable sort methods like an insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthIllegalArgumentException
- if target == coSort (as references).public static <T extends Comparable<T>> void quickSort1(T[] target, int fromIndex, int length, Object[] coSort)
quickSort(Comparable[], int, int, Object[])
, but without range checking.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.coSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if target == coSort (as references).public static <T extends Comparable<T>> void quickSort(T[] target, int[] coSort)
coSort
objects array in the same way then specified target
array. The code was taken from the jdk6 Arrays class. 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. NOTE: this is unstable sort
algorithm, so additional combinatorics of the coSort
array can be perfomed. Use this method only if you
are sure, in what you are doing. If not - use stable sort methods like an insertion sort or Tim sort.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if fromIndex > toIndexIllegalArgumentException
- if coSort length less then target length.IllegalArgumentException
- if target == coSort (as references).public static <T extends Comparable<T>> void quickSort(T[] target, int fromIndex, int toIndex, int[] coSort)
coSort
objects array in the same way then specified target
array. The range to be sorted extends from index fromIndex, inclusive, to index toIndex,
exclusive. (If fromIndex==toIndex, the range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the
coSort
array can be perfomed. Use this method only if you are sure, in what you are doing. If not - use
stable sort methods like an insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthIllegalArgumentException
- if target == coSort (as references).public static <T extends Comparable<T>> void quickSort1(T[] target, int fromIndex, int length, int[] coSort)
quickSort(Comparable[], int, int, Object[])
, but without range checking.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.coSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if target == coSort (as references).public static void swap(Object[] x, int a, int b)
public static void quickSort(int[] target, Object[] coSort)
coSort
Objects array in the same way as the target array. The code was taken from the jdk6 Arrays class.
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. NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be perfomed. Use this method only if you are sure, in what you are doing. If not - use stable
sort methods like an insertion sort or Tim sort.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static void quickSort(int[] target, int fromIndex, int toIndex, Object[] coSort)
coSort
Objects array in the same way as the target array. The range to be sorted extends
from index fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex,
the range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static void quickSort1(int[] target, int fromIndex, int length, Object[] coSort)
)
, but without range checking.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.coSort
- the array which will be permuted in the same way as the target array, during sorting procedurepublic static int[] quickSortP(short[] target)
public static void quickSort(short[] target, int fromIndex, int toIndex, int[] coSort)
coSort
ints array in the same way as the target array. The range to be sorted extends from
index fromIndex, inclusive, to index toIndex, exclusive. (If fromIndex==toIndex, the
range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE:
remember this is unstable sort algorithm, so additional combinatorics of the coSort
array can be
perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like an
insertion sort or Tim sort.
NOTE: The method throws IllegalArgumentException
if target == coSort
, because in this case no sorting will be perfomed.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcoSort
- the array which will be permuted in the same way as the target array, during sorting procedureIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static void quickSort1(short[] target, int fromIndex, int length, int[] coSort)
quickSort(int[], int, int, int[])
, but without range checking and toIndex ->
length (see params). Throws IllegalArgumentException
if target == coSort
, because in this case no
sorting will be perfomed . NOTE: this is unstable sort algorithm, so additional combinatorics of the
coSort
array can be perfomed. Use this method only if you are sure, in what you are doing. If not - use
stable sort methods like an insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.coSort
- the array which will be permuted in the same way as the target array, during sorting procedurepublic static void quickSort(short[] target, int[] coSort)
coSort
ints array in the same way as the target array. The code was taken from the jdk6 Arrays class.
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.
NOTE: remember this is unstable sort algorithm, so additional combinatorics of the coSort
array can
be perfomed. Use this method only if you are sure, in what you are doing. If not - use stable sort methods like
an insertion sort or Tim sort.
NOTE: The method throws IllegalArgumentException
if
target == coSort
, because in this case no sorting will be perfomed.
target
- the array to be sortedcoSort
- the array which will be permuted in the same way as the target array during sorting procedureIllegalArgumentException
- if coSort length less then target length.public static void quickSort(int[] target, IntComparator comparator)
IntComparator
using quicksort.target
- the array to be sortedcomparator
- custom comparatorIllegalArgumentException
- if coSort length less then target length.public static void quickSort(int[] target, int fromIndex, int toIndex, IntComparator comparator)
IntComparator
using quicksort.target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcomparator
- comparatorIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthpublic static void quickSort1(int[] target, int fromIndex, int length, IntComparator comparator)
IntComparator
using quicksort.target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedlength
- the length of the sorting subarray.comparator
- comparatorpublic static void quickSort(int[] target, int[] cosort, IntComparator comparator)
IntComparator
and simultaneously permutes the
coSort
Objects array in the same way as the target array. The code was taken from the jdk6 Arrays
class. 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. NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be perfomed. Use this method only if you are sure, in what you are doing. If not - use stable
sort methods like an insertion sort or Tim sort.
target
- the array to be sortedcomparator
- custom comparatorIllegalArgumentException
- if coSort length less then target length.public static void quickSort(int[] target, int fromIndex, int toIndex, int[] cosort, IntComparator comparator)
IntComparator
and
simultaneously permutes the coSort
Objects array in the same way as the target array. The range to be
sorted extends from index fromIndex, inclusive, to index toIndex, exclusive. (If
fromIndex==toIndex, the range to be sorted is empty.)The code was taken from the jdk6 Arrays class. 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.
NOTE: this is unstable sort algorithm, so additional combinatorics of the coSort
array can be perfomed. Use this method only if you are sure, in what you are doing. If not - use stable
sort methods like an insertion sort or Tim sort.
target
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be sortedtoIndex
- the index of the last element (exclusive) to be sortedcomparator
- comparatorIllegalArgumentException
- if fromIndex > toIndexArrayIndexOutOfBoundsException
- if fromIndex < 0 or toIndex > target.length or
toIndex > coSort.lengthCopyright © 2018. All rights reserved.