Module org.chocosolver
Class IntervalTree<T extends Interval>
 java.lang.Object

 org.chocosolver.util.objects.tree.IntervalTree<T>

 Type Parameters:
T
  the type of Interval this tree contains
 All Implemented Interfaces:
Iterable<T>
public class IntervalTree<T extends Interval> extends Object implements Iterable<T>
The following class is adapted from: a balanced binarysearch tree keyed by Interval objects.The underlying datastructure is a redblack tree largely implemented from CLRS (Introduction to Algorithms, 2nd edition) with the intervaltree extensions mentioned in section 14.3
 Author:
 Mason M Lai


Constructor Summary
Constructors Constructor Description IntervalTree()
Constructs an empty IntervalTree.

Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(T t)
Whether or not this IntervalTree contains the given Interval.boolean
delete(T t)
Deletes the given value from this IntervalTree.void
forAllAbove(int ub, Consumer<T> ex)
void
forAllBelow(int lb, Consumer<T> ex)
T
get(int s, int e)
Whether or not this IntervalTree contains the given Interval.boolean
insert(T t)
Inserts the given value into the IntervalTree.boolean
isEmpty()
Whether this IntervalTree is empty or not.Iterator<T>
iterator()
An Iterator which traverses the tree in ascending order.Optional<T>
maximum()
The maximum value in this IntervalTreeOptional<T>
minimum()
The minimum value in this IntervalTreeIterator<T>
overlappers(int start, int end)
An Iterator over the Intervals in this IntervalTree that overlap the given Intervalint
size()
The number of intervals stored in this IntervalTree.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface java.lang.Iterable
forEach, spliterator




Method Detail

isEmpty
public boolean isEmpty()
Whether this IntervalTree is empty or not.

size
public int size()
The number of intervals stored in this IntervalTree.

contains
public boolean contains(T t)
Whether or not this IntervalTree contains the given Interval. Parameters:
t
  the Interval to search for

get
public T get(int s, int e)
Whether or not this IntervalTree contains the given Interval. Parameters:
s
  the starting time of the Interval to search fore
  the ending time of the Interval to search for

minimum
public Optional<T> minimum()
The minimum value in this IntervalTree Returns:
 an Optional containing, if it exists, the minimum value in this IntervalTree; otherwise (i.e., if this is empty), an empty Optional.

maximum
public Optional<T> maximum()
The maximum value in this IntervalTree Returns:
 an Optional containing, if it exists, the maximum value in this IntervalTree; otherwise (i.e., if this is empty), an empty Optional.

overlappers
public Iterator<T> overlappers(int start, int end)
An Iterator over the Intervals in this IntervalTree that overlap the given Interval Parameters:
start
  the starting point of the overlapping Intervalend
  the ending point of the overlapping Interval

insert
public boolean insert(T t)
Inserts the given value into the IntervalTree.This method constructs a new Node containing the given value and places it into the tree. If the value already exists within the tree, the tree remains unchanged.
 Parameters:
t
  the value to place into the tree Returns:
 if the value did not already exist, i.e., true if the tree was changed, false if it was not

delete
public boolean delete(T t)
Deletes the given value from this IntervalTree.If the value does not exist, this IntervalTree remains unchanged.
 Parameters:
t
  the Interval to delete from the tree Returns:
 whether or not an Interval was removed from this IntervalTree

