org.jaitools.numeric
Class RangeComparator<T extends Number & Comparable>
java.lang.Object
org.jaitools.numeric.RangeComparator<T>
- Type Parameters:
T - range value type
- All Implemented Interfaces:
- Comparator<Range<T>>
public class RangeComparator<T extends Number & Comparable>
- extends Object
- implements Comparator<Range<T>>
Compares ranges by min end-point, then max end-point. This reduces the
detailed comparison available from RangeExtendedComparator to
an integer result that is compatible with generic sorting methods such
as
Collections.sort(java.util.List, Comparator).
| Result | Meaning |
| negative |
either r1 min is less than r2 min or r1 max is less than r2 max |
| zero |
r1 and r2 are equal |
| positive |
either r1 min is greater than r2 min or r1 max is greater than r2 max |
- Author:
- michael
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RangeComparator
public RangeComparator()
- Creates a new comparator.
RangeComparator
public RangeComparator(RangeExtendedComparator<T> ec)
- Creates a new comparator that will use the supplied extended comparator.
- Parameters:
ec - extended comparator (may be null)
compare
public int compare(Range<T> r1,
Range<T> r2)
- Compares two ranges.
Returns a negative value if r1 min is less than r2 min OR r1 max is less
than r2 max; a positive value if r1 min is greater than r2 min OR r2
max is greater than r2 max; or zero if the ranges are identical.
- Specified by:
compare in interface Comparator<Range<T extends Number & Comparable>>
- Parameters:
r1 - first ranger2 - second range
Copyright © 2009-2015. All Rights Reserved.