edu.umd.cfar.lamp.viper.util
Interface IntervalIndexList

All Known Subinterfaces:
TemporalRange
All Known Implementing Classes:
InstantRange, MultipleRange, Range, TimeEncodedList

public interface IntervalIndexList

A list of items that is indexed not by integers but by Comparable objects.


Nested Class Summary
static interface IntervalIndexList.Change
          Function object interface for the map method of the list.
 
Method Summary
 boolean addAll(IntervalIndexList l)
          Adds all the elements from the given list at their specified locations
 void clear()
          Removes all elements from the list.
 java.lang.Comparable endOf(java.lang.Comparable c)
          Gets the end of the element in which c is contained.
 java.lang.Comparable firstAfter(java.lang.Comparable c)
          Gets the start of the first element that begins strictly after c.
 java.lang.Comparable firstAfterOrAt(java.lang.Comparable c)
          Gets the start of the first element that begins at c or after it.
 java.lang.Comparable firstBefore(java.lang.Comparable c)
          Gets the start of the first element before c, exclusive.
 java.lang.Object get(java.lang.Comparable index)
          Get the value at the specified index in the list.
 int getContiguousIntervalCount()
          Gets a count of the contiguous (and homogenous, for those sort of things) intervals in the list.
 boolean isEmpty()
          True if no elements are described in the list.
 java.util.Iterator iterator()
          Gets an iterator over all the Interval objects here.
 java.util.Iterator iterator(Interval i)
          Gets an iterator over all the Interval objects that intersect the given Interval.
 void map(IntervalIndexList.Change c)
          Changes all the values of the elements by the given change function object.
 boolean remove(java.lang.Comparable start, java.lang.Comparable stop)
          Removes all values at the given range.
 void set(java.lang.Comparable start, java.lang.Comparable stop, java.lang.Object value)
          Sets the value at the given range.
 IntervalIndexList subList(java.lang.Comparable start, java.lang.Comparable stop)
          Gets the sublist in the given interval
 

Method Detail

get

public java.lang.Object get(java.lang.Comparable index)
Get the value at the specified index in the list.

Parameters:
index - the index into the list
Returns:
the value at the specified index

set

public void set(java.lang.Comparable start,
                java.lang.Comparable stop,
                java.lang.Object value)
Sets the value at the given range. Note that, like SortedMap, this means that value is set in the range from start, inclusive, to stop, exclusive.

Parameters:
start - the first index to set
stop - the first index that is not set
value - all elements in the list in the range [start, stop) will take this value
Throws:
java.lang.IllegalArgumentException - if start is not less than stop

remove

public boolean remove(java.lang.Comparable start,
                      java.lang.Comparable stop)
Removes all values at the given range. Note that, like SortedMap, this means that value is set in the range from start, inclusive, to stop, exclusive.

Parameters:
start - the first index to remove
stop - the first index that is not removed
Returns:
true if any elements were removed

iterator

public java.util.Iterator iterator()
Gets an iterator over all the Interval objects here. Note that, if the

Returns:

iterator

public java.util.Iterator iterator(Interval i)
Gets an iterator over all the Interval objects that intersect the given Interval.

Returns:

addAll

public boolean addAll(IntervalIndexList l)
Adds all the elements from the given list at their specified locations

Parameters:
l - the list to add
Returns:
true if this changed

subList

public IntervalIndexList subList(java.lang.Comparable start,
                                 java.lang.Comparable stop)
Gets the sublist in the given interval

Parameters:
start - the start of the chop, inclusive
stop - the end of the chop, exclusive
Returns:
a sublist. It may be wired to the containing list, or may be a copy or immutable, depending on the implementor

firstBefore

public java.lang.Comparable firstBefore(java.lang.Comparable c)
Gets the start of the first element before c, exclusive.

Parameters:
c - Where to start looking backwards from
Returns:
the start of the last element that starts before c; null if none found

firstAfterOrAt

public java.lang.Comparable firstAfterOrAt(java.lang.Comparable c)
Gets the start of the first element that begins at c or after it.

Parameters:
c - the place to start looking
Returns:
the start of the first element after or at c; null if none found

firstAfter

public java.lang.Comparable firstAfter(java.lang.Comparable c)
Gets the start of the first element that begins strictly after c.

Parameters:
c - the place to start looking
Returns:
the start of the first element after c; null if none found

endOf

public java.lang.Comparable endOf(java.lang.Comparable c)
Gets the end of the element in which c is contained.

Parameters:
c - the element to check
Returns:
the end, if found; null if c isn't within an interval described by this list

clear

public void clear()
Removes all elements from the list.


isEmpty

public boolean isEmpty()
True if no elements are described in the list.

Returns:
!iterator().hasNext()

map

public void map(IntervalIndexList.Change c)
Changes all the values of the elements by the given change function object.

Parameters:
c - the method to apply to all elements

getContiguousIntervalCount

public int getContiguousIntervalCount()
Gets a count of the contiguous (and homogenous, for those sort of things) intervals in the list.

Returns: