csli.util.math
Interface Interval


public interface Interval

A single contiguous interval subset of some Comparable class. The interval is specified by a lower and upper bound and a closedness for each bound. In the constructor and getBound methods, null signifies that the bound is infinite, but all other uses of null to represent infinity are forbidden. Use the set/get infinite() methods instead. Simple intervals come in three flavors: ranges, singletons and empties. Ranges are those where the lower bound is less than the upper (the interval contains more than one element). Singletons are those with equal bounds of which at least one is closed (the interval contains exactly one element). All other intervals are deemed empty (contain no elements). All the Comparable objects must be of the same class for each interval. Otherwise, a ClassCastException is thrown when they are compared.

Author:
niekrasz

Method Summary
 Comparable getLowerBound()
          Get the lower bound.
 Comparable getUpperBound()
          Get the upper bound.
 boolean isEmpty()
          Is the interval empty (contains no elements)?
 boolean isLowerBoundClosed()
          Is the lower bound closed.
 boolean isLowerInfinite()
          Is the lower bound negative-infinity?
 boolean isLowerThan(Interval interval)
          Are all the elements of this interval less than all the elements of the specified interval? If either are empty, false.
 boolean isOverlappedBy(Interval interval)
          Is there a element such that both this and the specified interval contain it? If either are empty, false.
 boolean isRange()
          Is the upper bound greater than the lower bound? (is there more than one element in the interval)
 boolean isRangeOverlappedBy(Interval interval)
          Is there a range of elements which are shared by this and the specified interval?
 boolean isSingleton()
          Are the bounds equal and is at least one of them closed (contains exactly one element)?
 boolean isSupersetOf(Comparable element)
          Is the specified element a member of the interval? A null specified element causes an error.
 boolean isUpperBoundClosed()
          Is the upper bound closed.
 boolean isUpperInfinite()
          Is the upper bound positive infinity?
 void setLowerBound(Comparable comparable)
          Set the lower bound.
 void setLowerBoundClosed(boolean b)
          Set the closedness of the lower bound.
 void setLowerInfinite(boolean b)
          Set the lower bound to be negative-inifinity.
 void setUpperBound(Comparable comparable)
          Set the upper bound.
 void setUpperBoundClosed(boolean b)
          Set the closedness of the upper bound.
 void setUpperInfinite(boolean b)
          Set the upper bound to be positive-infinity.
 

Method Detail

getLowerBound

Comparable getLowerBound()
Get the lower bound. Null signifies positive infinity.


getUpperBound

Comparable getUpperBound()
Get the upper bound. Null signifies positive infinity.


isEmpty

boolean isEmpty()
Is the interval empty (contains no elements)?


isLowerBoundClosed

boolean isLowerBoundClosed()
Is the lower bound closed. Will be open if lower bound is infinite.


isLowerInfinite

boolean isLowerInfinite()
Is the lower bound negative-infinity?


isLowerThan

boolean isLowerThan(Interval interval)
Are all the elements of this interval less than all the elements of the specified interval? If either are empty, false.


isOverlappedBy

boolean isOverlappedBy(Interval interval)
Is there a element such that both this and the specified interval contain it? If either are empty, false.


isRange

boolean isRange()
Is the upper bound greater than the lower bound? (is there more than one element in the interval)


isRangeOverlappedBy

boolean isRangeOverlappedBy(Interval interval)
Is there a range of elements which are shared by this and the specified interval?


isSingleton

boolean isSingleton()
Are the bounds equal and is at least one of them closed (contains exactly one element)?


isSupersetOf

boolean isSupersetOf(Comparable element)
Is the specified element a member of the interval? A null specified element causes an error.


isUpperBoundClosed

boolean isUpperBoundClosed()
Is the upper bound closed. Will be open if upper bound is infinite.


isUpperInfinite

boolean isUpperInfinite()
Is the upper bound positive infinity?


setLowerBound

void setLowerBound(Comparable comparable)
Set the lower bound.


setLowerBoundClosed

void setLowerBoundClosed(boolean b)
Set the closedness of the lower bound.


setLowerInfinite

void setLowerInfinite(boolean b)
Set the lower bound to be negative-inifinity.


setUpperBound

void setUpperBound(Comparable comparable)
Set the upper bound. Null throws an error.


setUpperBoundClosed

void setUpperBoundClosed(boolean b)
Set the closedness of the upper bound.


setUpperInfinite

void setUpperInfinite(boolean b)
Set the upper bound to be positive-infinity.