org.jaitools.numeric
Class RangeExtendedComparator<T extends Number & Comparable>

java.lang.Object
  extended by org.jaitools.numeric.RangeExtendedComparator<T>
Type Parameters:
T - the numeric type

public class RangeExtendedComparator<T extends Number & Comparable>
extends Object

A comparator for Range objects capable of discerning the 18 different possible interval comparisons as described by:

Brian Hayes (2003) A lucid interval.
American Scientist 91(6):484-488.

Available at: http://www.cs.utep.edu/interval-comp/hayes.pdf

Constants describing each of these possible comparisons are defined in the RangeComparator.Result class.

Normally, client code will not need to use the methods defined in this class directly but will work through the Range class.

Since:
1.0
Version:
$Id$
Author:
Michael Bedward

Nested Class Summary
static class RangeExtendedComparator.Result
          Constants defining the names, notation and descriptions for the 18 different possible interval comparisons as described by: Brian Hayes (2003) A lucid interval.
 
Field Summary
static int EQ
          Constant for "equal to".
static int GT
          Constant for "greater than".
static int LT
          Constant for "less than".
static int MAX_MAX
          Index of RangeExtendedComparator.Result element for the comparison of the max value of the first Range with the max value of the second range.
static int MAX_MIN
          Index of RangeExtendedComparator.Result element for the comparison of the max value of the first Range with the min value of the second range.
static int MIN_MAX
          Index of RangeExtendedComparator.Result element for the comparison of the min value of the first Range with the max value of the second range.
static int MIN_MIN
          Index of RangeExtendedComparator.Result element for the comparison of the min value of the first Range with the min value of the second range.
 
Constructor Summary
RangeExtendedComparator()
           
 
Method Summary
 RangeExtendedComparator.Result compare(Range<T> r1, Range<T> r2)
          Compares two Range objects and return the RangeComparator.Result that describes the relationship between them from the point of view of the first Range
static boolean isIntersection(RangeExtendedComparator.Result r)
          Tests if a Result value describes an intersection between two ranges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LT

public static final int LT
Constant for "less than".

See Also:
Constant Field Values

EQ

public static final int EQ
Constant for "equal to".

See Also:
Constant Field Values

GT

public static final int GT
Constant for "greater than".

See Also:
Constant Field Values

MIN_MAX

public static final int MIN_MAX
Index of RangeExtendedComparator.Result element for the comparison of the min value of the first Range with the max value of the second range.

See Also:
Constant Field Values

MIN_MIN

public static final int MIN_MIN
Index of RangeExtendedComparator.Result element for the comparison of the min value of the first Range with the min value of the second range.

See Also:
Constant Field Values

MAX_MAX

public static final int MAX_MAX
Index of RangeExtendedComparator.Result element for the comparison of the max value of the first Range with the max value of the second range.

See Also:
Constant Field Values

MAX_MIN

public static final int MAX_MIN
Index of RangeExtendedComparator.Result element for the comparison of the max value of the first Range with the min value of the second range.

See Also:
Constant Field Values
Constructor Detail

RangeExtendedComparator

public RangeExtendedComparator()
Method Detail

isIntersection

public static boolean isIntersection(RangeExtendedComparator.Result r)
Tests if a Result value describes an intersection between two ranges.

Parameters:
r - the Result value
Returns:
true if r represents an intersection; false otherwise

compare

public RangeExtendedComparator.Result compare(Range<T> r1,
                                              Range<T> r2)
Compares two Range objects and return the RangeComparator.Result that describes the relationship between them from the point of view of the first Range

Parameters:
r1 - the first Range
r2 - the second Range
Returns:
a RangeComparator.Result constant


Copyright © 2009-2013. All Rights Reserved.