Class CoordinateSequenceComparator

Hierarchy: Object , CoordinateSequenceComparator
All Implemented Interfaces: Comparator
public class CoordinateSequenceComparator
implements Comparator
Compares two CoordinateSequences. For sequences of the same dimension, the ordering is lexicographic. Otherwise, lower dimensions are sorted before higher. The dimensions compared can be limited; if this is done ordinate dimensions above the limit will not be compared.

If different behaviour is required for comparing size, dimension, or coordinate values, any or all methods can be overridden.

public CoordinateSequenceComparator()
Creates a comparator which will test all dimensions.
public CoordinateSequenceComparator(int dimensionLimit)
Creates a comparator which will test only the specified number of dimensions.
Parameters:
dimensionLimit - dimensionLimit the number of dimensions to test
public static int compare(double a, double b)
Compare two doubles, allowing for NaN values. NaN is treated as being less than any valid number.
Parameters:
a - a a double
b - b a double
Returns:
-1, 0, or 1 depending on whether a is less than, equal to or greater than b
public int compare(Object o1, Object o2)
Compares two CoordinateSequences for relative order.
Parameters:
o1 - o1 a CoordinateSequence
o2 - o2 a CoordinateSequence
Returns:
-1, 0, or 1 depending on whether o1 is less than, equal to, or greater than o2
protected int compareCoordinate(CoordinateSequence s1, CoordinateSequence s2, int i, int dimension)
Compares the same coordinate of two CoordinateSequences along the given number of dimensions.
Parameters:
s1 - s1 a CoordinateSequence
s2 - s2 a CoordinateSequence
i - i the index of the coordinate to test
dimension - dimension the number of dimensions to test
Returns:
-1, 0, or 1 depending on whether s1[i] is less than, equal to, or greater than s2[i]