SSJ
V. 2.4.

umontreal.iro.lecuyer.util
Class SplitSort

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

public class SplitSort
extends Object
implements MultiDimSort

This class implements a MultiDimSort that performs a split 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 split sort first separates the array in two, such that objects in the first part are smaller or equal, in dimension 1 (coordinate 0), to the objects in the second part. Then it recursively separates each part in two for the dimension 2 (coordinate 1), and so on. When the maximum dimension (coordinate dimension() - 1) is reached, it cycles back to coordinate 0, until each part contains only 1 object.


Constructor Summary
SplitSort(int d)
          Constructs a SplitSort that will use the first d dimensions to sort.
 
Method Summary
 int dimension()
          Maximum dimension used for 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

SplitSort

public SplitSort(int d)
Constructs a SplitSort that will use the first d dimensions to sort.

Parameters:
d - maximum dimension to use for the sort
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()
Maximum dimension used for the sort. Sort coordinates vary from 0 to dimension() - 1.

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

SSJ
V. 2.4.

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