collectionframework
Class SimpleIntervalIndexedCollection<E>

java.lang.Object
  extended by collectionframework.SimpleIntervalIndexedCollection<E>
All Implemented Interfaces:
IntervalIndexedCollection<E>

public class SimpleIntervalIndexedCollection<E>
extends java.lang.Object
implements IntervalIndexedCollection<E>

A collection of objects that is indexed by an interval That is, instead of a each element in the collection being associated with a single index i, each element is associated with a closed interval [a, b] NOTE: This is an easy implementation but not a good one. A better approach is to use an interval tree. See, for example, Cormen et al. (2001) and the references therein.

See Also:
"The Design and Implementation of Multimedia Software © 2011"

Constructor Summary
SimpleIntervalIndexedCollection()
          Default Constructor
 
Method Summary
 void add(E element, int left, int right)
          Add an element to this collection
 java.util.Iterator<E> get(int i)
          Get all of the elements at point i (i.e., all of the elements with intervals that include i)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleIntervalIndexedCollection

public SimpleIntervalIndexedCollection()
Default Constructor

Method Detail

add

public void add(E element,
                int left,
                int right)
Add an element to this collection

Specified by:
add in interface IntervalIndexedCollection<E>
Parameters:
element - The element to add
left - The left-most point in the closed interval
right - The right-most point in the closed interval

get

public java.util.Iterator<E> get(int i)
Get all of the elements at point i (i.e., all of the elements with intervals that include i)

Specified by:
get in interface IntervalIndexedCollection<E>
Parameters:
i - The point of interest
Returns:
The elements at that point


Design and Implementation of Multimedia Software, Jones and Bartlett Publishers