Package org.ow2.clif.jenkins.parser.clif
Class DoubleArraySorter
 java.lang.Object

 org.ow2.clif.jenkins.parser.clif.DoubleArraySorter

public class DoubleArraySorter extends Object
This class contains various methods for manipulating arrays (such as sorting and searching). This class also contains a static factory that allows arrays to be viewed as lists.
All methods in this class throw aNullPointerException
if the specified array reference is null, except where noted.
The documentation for the methods contained in this class includes briefs description of the implementations. Such descriptions should be regarded as implementation notes, rather than parts of the specification. Implementors should feel free to substitute other algorithms, so long as the specification itself is adhered to. (For example, the algorithm used bysort(Object[])
does not have to be a mergesort, but it does have to be stable.)
This class is a member of the Java Collections Framework. Since:
 1.2
 Version:
 1.71, 04/21/06
 Author:
 Josh Bloch, Neal Gafter, John Rose


Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
sort(double[] first, double[] second)
Sorts the specified arrays of doubles into ascending numerical order.static void
sort(double[] first, double[] second, int fromIndex, int toIndex)
Sorts the specified range of the specified arrays of doubles into ascending numerical order.



Method Detail

sort
public static void sort(double[] first, double[] second)
Sorts the specified arrays of doubles into ascending numerical order. Only the first array is used to sort. The second array is sorted using the same order as the first one
The<
relation does not provide a total order on all floatingpoint values; although they are distinct numbers0.0 == 0.0
istrue
and a NaN value compares neither less than, greater than, nor equal to any floatingpoint value, even itself. To allow the sort to proceed, instead of using the<
relation to determine ascending numerical order, this method uses the total order imposed byDouble.compareTo(java.lang.Double)
. This ordering differs from the<
relation in that0.0
is treated as less than0.0
and NaN is considered greater than any other floatingpoint value. For the purposes of sorting, all NaN values are considered equivalent and equal.
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", SoftwarePractice and Experience, Vol. 23(11) P. 12491265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. Parameters:
first
 the array to be sortedsecond
 second array to be sorted

sort
public static void sort(double[] first, double[] second, int fromIndex, int toIndex)
Sorts the specified range of the specified arrays of doubles into ascending numerical order. Sorts the specified arrays of doubles into ascending numerical order. Only the first array is used to sort. The second array is sorted using the same order as the first one The range to be sorted extends from indexfromIndex
, inclusive, to indextoIndex
, exclusive. (IffromIndex==toIndex
, the range to be sorted is empty.)
The<
relation does not provide a total order on all floatingpoint values; although they are distinct numbers0.0 == 0.0
istrue
and a NaN value compares neither less than, greater than, nor equal to any floatingpoint value, even itself. To allow the sort to proceed, instead of using the<
relation to determine ascending numerical order, this method uses the total order imposed byDouble.compareTo(java.lang.Double)
. This ordering differs from the<
relation in that0.0
is treated as less than0.0
and NaN is considered greater than any other floatingpoint value. For the purposes of sorting, all NaN values are considered equivalent and equal.
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", SoftwarePractice and Experience, Vol. 23(11) P. 12491265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance. Parameters:
first
 the array to be sortedsecond
 second array to be sortedfromIndex
 the index of the first element (inclusive) to be sortedtoIndex
 the index of the last element (exclusive) to be sorted Throws:
IllegalArgumentException
 iffromIndex > toIndex
ArrayIndexOutOfBoundsException
 iffromIndex < 0
ortoIndex > a.length

