public class BatchSort extends java.lang.Object implements MultiDimSort
MultiDimSort that performs a batch
sort on the arrays.
For MultiDimComparable objects, the dimension mentioned
below refers to the value returned by
dimension.
The ordering of the elements is the one induced by the method
compareTo.
The batch sort separates the objects in n1 batches of equal size such that each object in a batch is smaller or equal, in dimension 1, to the objects in the next batches. Then, each batch is separated in n2 batches the same way but in dimension 2. And so on. The integers n1, n2,…, nd are given in the array batches in the constructor. The variable d must be smaller or equal to the dimension of the objects, and the product n1n2 ... nd must equal the number of objects in the array.
Batches can also be determined by an array of doubles α1, α2,…, αd, such that ni = nαi, where n is the number of objects in the array. This way, the condition on the batches is that the sum α1 + α2 + ... + αd must equal 1.
| Constructor and Description |
|---|
BatchSort(double[] batchesExponents)
Constructs a
BatchSort that will use
batchesExponents. |
BatchSort(int[] batches)
Constructs a
BatchSort that will use batches. |
| Modifier and Type | Method and Description |
|---|---|
int |
dimension()
Returns the greatest dimension used in the sort.
|
void |
sort(double[][] a)
Sorts the entire array.
|
void |
sort(double[][] a,
int iMin,
int iMax)
Sorts the subarray of a made of the elements with indices from
iMin to iMax-1.
|
<T extends MultiDimComparable<? super T>> |
sort(T[] a)
Sorts the entire array.
|
<T extends MultiDimComparable<? super T>> |
sort(T[] a,
int iMin,
int iMax)
Sorts the subarray of a made of the elements with indices from
iMin to iMax-1.
|
public BatchSort(int[] batches)
BatchSort that will use batches. The
product of elements in batches must equal the size of the
arrays to sort; it is verified in sort.batches - number of batches in each dimensionpublic BatchSort(double[] batchesExponents)
BatchSort that will use
batchesExponents. Sum of batchesExponents must
equal 1 or an IllegalArgumentException
is thrown.batchesExponents - exponents to compute the batches sizespublic <T extends MultiDimComparable<? super T>> void sort(T[] a, int iMin, int iMax)
MultiDimSortsort in interface MultiDimSorta - array to sortiMin - index of first element to sortiMax - index of last element to sort is
public <T extends MultiDimComparable<? super T>> void sort(T[] a)
MultiDimSortsort in interface MultiDimSorta - array to sortpublic void sort(double[][] a,
int iMin,
int iMax)
MultiDimSortsort in interface MultiDimSorta - array to sortiMin - index of first element to sortiMax - index of last element to sort is
public void sort(double[][] a)
MultiDimSortsort in interface MultiDimSorta - array to sortpublic int dimension()
MultiDimSortdimension in interface MultiDimSortTo submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.