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
An interval tree implementation to store activities based on their start and
end time.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Adds an activity to the tree.final void
clear()
Removes all activities from the tree.final Instant
Returns the earliest time used by all activities currently stored inside the tree.final Collection<A>
getIntersectingObjects
(long start, long end) Returns all activities found within the given time interval.final Collection<A>
getIntersectingObjects
(TimeInterval interval) Returns all activities found within the given time interval.final Instant
Returns the latest time used by all activities currently stored inside the tree.final boolean
Method to remove period/key object from tree.final boolean
final Collection<A>
removePeriod
(TimeInterval interval) Removes all activities found within the given time interval.final 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.
-