E - the objects stored by this.public class CenteredIntIntervalTree<E extends IntInterval & java.lang.Comparable<E>> extends java.lang.Object implements IntIntervalTree<E>
Class CenteredIntIntervalTree implements a centered
interval tree that stores IntInterval objects.
CenteredIntIntervalTree are not thread-safe.| Constructor and Description |
|---|
CenteredIntIntervalTree(int start,
int end)
Creates a new
CenteredIntIntervalTree instance for the
specified range. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E element)
Adds the specified element to this interval tree, and returns
true if the interval tree is changed as a result of
the call. |
void |
clear()
Removes all of the elements from this interval tree.
|
boolean |
contains(E element)
Returns
true if the interval tree contains the specified
element, and returns false otherwise. |
int |
end()
Returns the maximum end (inclusive) of an interval
that can be stored in this interval tree.
|
void |
intersect(int point,
java.util.Collection<E> collection)
Adds the elements in this interval tree that intersect the specified
point to the specified collection.
|
void |
intersectAll(int start,
int end,
java.util.Collection<E> collection)
Adds the elements in this interval tree that contain
the specified interval to the specified collection.
|
void |
intersectPart(int start,
int end,
java.util.Collection<E> collection)
Adds the elements in this interval tree that intersect any part of
the specified interval to the specified collection.
|
boolean |
isEmpty()
Returns
true if this interval tree contains no elements. |
boolean |
remove(E element)
Removes the specified element from this interval tree if the
specified element is found in the interval tree.
|
int |
size()
Returns the number of elements in this interval tree.
|
int |
start()
Returns the minimum start (inclusive) of an interval
that can be stored in this interval tree.
|
E[] |
toArray()
Returns an array containing all of the elements of this interval tree.
|
java.lang.String |
toString()
Returns a string representation of
this. |
public CenteredIntIntervalTree(int start,
int end)
CenteredIntIntervalTree instance for the
specified range.start - the minimum start value (inclusive) for intervals stored in
this interval treeend - the maximum end value (inclusive) for intervals stored
in this interval treejava.lang.IllegalArgumentException - if end < startpublic int start()
IntIntervalTreestart in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>public int end()
IntIntervalTreeend in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>public void clear()
IntIntervalTreeclear in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>public boolean add(E element)
IntIntervalTreetrue if the interval tree is changed as a result of
the call. The method returns false if
this.contains(E) == true when the method is invoked.add in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>element - the element to be addedtrue if the interval tree changed as
a result of the callpublic boolean contains(E element)
IntIntervalTreetrue if the interval tree contains the specified
element, and returns false otherwise.contains in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>element - the element whose presence in the interval tree
is to be testedtrue if the interval tree contains the specified
elementpublic boolean remove(E element)
IntIntervalTreeremove in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>element - the element to be removed from this interval treetrue if the interval tree is changed as
a result of the callpublic void intersect(int point,
java.util.Collection<E> collection)
IntIntervalTreeintersect in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>point - a pointcollection - a collection to which will be added the elements of
this interval tree that intersect the specified pointpublic void intersectPart(int start,
int end,
java.util.Collection<E> collection)
IntIntervalTreeintersectPart in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>start - the start (inclusive) of the specified intervalend - the end (inclusive) of the specified intervalcollection - a collection to which will be added the elements of
this interval tree that intersect any part of the specified intervalpublic void intersectAll(int start,
int end,
java.util.Collection<E> collection)
IntIntervalTreeintersectAll in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>start - the start (inclusive) of the specified intervalend - the end (inclusive) of the specified intervalcollection - a collection to which will be added the elements
of this interval tree that contain the specified intervalpublic boolean isEmpty()
IntIntervalTreetrue if this interval tree contains no elements.isEmpty in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>true if this interval tree contains no elementspublic int size()
IntIntervalTreesize in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>public E[] toArray()
IntIntervalTreetoArray in interface IntIntervalTree<E extends IntInterval & java.lang.Comparable<E>>public java.lang.String toString()
this. The
exact details of the representation are unspecified and
subject to change.toString in class java.lang.Objectthis