Module com.flexganttfx.model
Package com.flexganttfx.model.util
Class IntervalTree<A extends Activity>
java.lang.Object
com.flexganttfx.model.util.IntervalTree<A>
- Type Parameters:
A
- the activity type
public class IntervalTree<A extends Activity> extends Object
An interval tree implementation to store activities based on their start and
end time.
- See Also:
IntervalTreeActivityRepository
-
Constructor Summary
Constructors Constructor Description IntervalTree()
-
Method Summary
Modifier and Type Method Description boolean
add(A activity)
Adds an activity to the tree.void
clear()
Removes all activities from the tree.Instant
getEarliestTimeUsed()
Returns the earliest time used by all activities currently stored inside the tree.Collection<A>
getIntersectingObjects(long start, long end)
Returns all activities found within the given time interval.Collection<A>
getIntersectingObjects(TimeInterval interval)
Returns all activities found within the given time interval.Instant
getLatestTimeUsed()
Returns the latest time used by all activities currently stored inside the tree.boolean
remove(A activity)
Method to remove period/key object from tree.boolean
removeIf(Predicate<A> predicate)
Collection<A>
removePeriod(TimeInterval interval)
Removes all activities found within the given time interval.long
size()
Returns the number of activities stored inside the tree.
-
Constructor Details
-
IntervalTree
public IntervalTree()
-
-
Method Details
-
getEarliestTimeUsed
Returns the earliest time used by all activities currently stored inside the tree.- Returns:
- the earliest time used
-
getLatestTimeUsed
Returns the latest time used by all activities currently stored inside the tree.- Returns:
- the latest time used
-
add
Adds an activity to the tree.- Parameters:
activity
- the activity to add- Returns:
- true if the activity could be added
-
remove
Method to remove period/key object from tree. Entry to delete will be found by period and key values of given activity (not by given object reference).- Parameters:
activity
- the activity to remove- Returns:
- true if the activity was a member of this tree
-
removeIf
-
removePeriod
Removes all activities found within the given time interval.- Parameters:
interval
- the time interval- Returns:
- the removed activities
-
getIntersectingObjects
Returns all activities found within the given time interval.- Parameters:
interval
- the time interval- Returns:
- the found activities
-
getIntersectingObjects
Returns all activities found within the given time interval.- Parameters:
start
- the time interval startend
- the time interval end- Returns:
- the found activities
-
size
public final long size()Returns the number of activities stored inside the tree.- Returns:
- the tree size
-
clear
public final void clear()Removes all activities from the tree.
-