edu.umd.cfar.lamp.viper.util
Class AbstractInterval

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.AbstractInterval
All Implemented Interfaces:
Interval
Direct Known Subclasses:
AbstractInstantInterval, SimpleInterval

public abstract class AbstractInterval
extends java.lang.Object
implements Interval

An abstract base class for interval pairs of Comparable objects, such as BigIntegers or Instants.


Constructor Summary
AbstractInterval()
           
 
Method Summary
 Interval change(java.lang.Comparable start, java.lang.Comparable stop)
          Not implemented; throws unsupported operation exception.
 boolean contains(java.lang.Comparable i)
          Tests to see if the given item is within the interval.
 boolean contains(Interval other)
          Tests to see if the other interval is a subset of this interval.
 boolean contains(java.lang.Object o)
          Tests to see if the given object is contained within the interval.
 boolean contains(java.util.Set s)
          Tests to see that all elements of the set are contained within this interval.
 boolean equals(java.lang.Object o)
          Tests to see if this refers to the same interval as the other.
 int hashCode()
          Gets a hash code.
 boolean intersects(Interval other)
          Tests to see if this interval intersects the other one.
 boolean intersects(java.util.Set s)
          Assuming s contains instants or spans of the same type (Time or Frame), this will work.
 boolean isEmpty()
          Tests to see if any time is taken in the Span.
 java.lang.String toString()
          Gets a string version of the interval
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.umd.cfar.lamp.viper.util.Interval
getEnd, getStart
 

Constructor Detail

AbstractInterval

public AbstractInterval()
Method Detail

toString

public java.lang.String toString()
Gets a string version of the interval

Returns:
[start, end)

equals

public boolean equals(java.lang.Object o)
Tests to see if this refers to the same interval as the other.

Parameters:
o - the interval to test against
Returns:
true if the intervals are the same

hashCode

public int hashCode()
Gets a hash code.

Returns:
getStart().hashCode() ^ getEnd().hashCode()

isEmpty

public boolean isEmpty()
Tests to see if any time is taken in the Span.

Specified by:
isEmpty in interface Interval
Returns:
true if at least one Comparable is taken

intersects

public boolean intersects(java.util.Set s)
Assuming s contains instants or spans of the same type (Time or Frame), this will work. Otherwise may throw a ClassCastException.

Specified by:
intersects in interface Interval
Parameters:
s - set of Spans or Instants
Returns:
boolean

intersects

public boolean intersects(Interval other)
Tests to see if this interval intersects the other one.

Specified by:
intersects in interface Interval
Parameters:
other - the other interval to test
Returns:
true if there exists some object such that it is contained within this and the other interval.

contains

public boolean contains(java.lang.Object o)
Tests to see if the given object is contained within the interval. If it isn't a type that can be contained within the interval, returns false. Otherwise, it invokes one of the more specific versions of contains().

Parameters:
o - the object to test
Returns:
true if it is greater than or equal to start and strictly less than end

contains

public boolean contains(java.lang.Comparable i)
Tests to see if the given item is within the interval.

Specified by:
contains in interface Interval
Parameters:
i - the comparable object to look for
Returns:
true if it is greater than or equal to start and strictly less than end

contains

public boolean contains(Interval other)
Tests to see if the other interval is a subset of this interval.

Specified by:
contains in interface Interval
Parameters:
other - the interval to test
Returns:
true if other is a subset of this

contains

public boolean contains(java.util.Set s)
Tests to see that all elements of the set are contained within this interval.

Specified by:
contains in interface Interval
Parameters:
s - the items to check for
Returns:
true if this contains every element of s

change

public Interval change(java.lang.Comparable start,
                       java.lang.Comparable stop)
Not implemented; throws unsupported operation exception.

Specified by:
change in interface Interval
Parameters:
start - the start (inclusive)
stop - the end (exclusive)
Returns:
the new interval
Throws:
java.lang.UnsupportedOperationException