SSJ
V. labo.

umontreal.iro.lecuyer.util
Class BatchSort

java.lang.Object
  extended by umontreal.iro.lecuyer.util.BatchSort
All Implemented Interfaces:
MultiDimSort

public class BatchSort
extends Object
implements MultiDimSort

BatchSort

This class implements a MultiDimSort that performs a batch sort on the arrays.

For MultiDimComparable objects, the dimension mentioned below refers to the value returned by umontreal.iro.lecuyer.utilMultiDimComparabledimension. The ordering of the elements is the one induced by the method umontreal.iro.lecuyer.utilMultiDimComparablecompareTo.

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 Summary
BatchSort(double[] batchesExponents)
          .
BatchSort(int[] batches)
          .
 
Method Summary
 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>>
void
sort(T[] a)
          Sorts the entire array.
<T extends MultiDimComparable<? super T>>
void
sort(T[] a, int iMin, int iMax)
          Sorts the subarray of a made of the elements with indices from iMin to iMax-1.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchSort

public BatchSort(int[] batches)
. \begin{tabb}
 Constructs a \class{BatchSort} that will use \texttt{batches}. The
 ...
 ...al the size of the
 arrays to sort; it is verified in \method{sort}{}.
 \end{tabb}
batchesnumber of batches in each dimension


BatchSort

public BatchSort(double[] batchesExponents)
. \begin{tabb}
 Constructs a \class{BatchSort} that will use
 \texttt{batchesExponen...
 ... or an \externalclass{java.lang}{IllegalArgumentException}
 is thrown.
 \end{tabb}
batchesExponentsexponents to compute the batches sizes

Method Detail

sort

public <T extends MultiDimComparable<? super T>> void sort(T[] a,
                                                           int iMin,
                                                           int iMax)
Description copied from interface: MultiDimSort
Sorts the subarray of a made of the elements with indices from iMin to iMax-1.

Specified by:
sort in interface MultiDimSort
Parameters:
a - array to sort
iMin - index of first element to sort
iMax - index of last element to sort is iMax - 1

sort

public <T extends MultiDimComparable<? super T>> void sort(T[] a)
Description copied from interface: MultiDimSort
Sorts the entire array.

Specified by:
sort in interface MultiDimSort
Parameters:
a - array to sort

sort

public void sort(double[][] a,
                 int iMin,
                 int iMax)
Description copied from interface: MultiDimSort
Sorts the subarray of a made of the elements with indices from iMin to iMax-1.

Specified by:
sort in interface MultiDimSort
Parameters:
a - array to sort
iMin - index of first element to sort
iMax - index of last element to sort is iMax - 1

sort

public void sort(double[][] a)
Description copied from interface: MultiDimSort
Sorts the entire array.

Specified by:
sort in interface MultiDimSort
Parameters:
a - array to sort

dimension

public int dimension()
Description copied from interface: MultiDimSort
Returns the greatest dimension used in the sort.

Specified by:
dimension in interface MultiDimSort
Returns:
greatest dimension used for the sort

SSJ
V. labo.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.