Class IntervalTree<A extends Activity>

  • 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 Detail

      • IntervalTree

        public IntervalTree()
    • Method Detail

      • getEarliestTimeUsed

        public final Instant getEarliestTimeUsed()
        Returns the earliest time used by all activities currently stored inside the tree.
        Returns:
        the earliest time used
      • getLatestTimeUsed

        public final Instant getLatestTimeUsed()
        Returns the latest time used by all activities currently stored inside the tree.
        Returns:
        the latest time used
      • add

        public final boolean add​(A activity)
        Adds an activity to the tree.
        Parameters:
        activity - the activity to add
        Returns:
        true if the activity could be added
      • remove

        public final boolean remove​(A activity)
        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
      • removePeriod

        public final Collection<A> removePeriod​(TimeInterval interval)
        Removes all activities found within the given time interval.
        Parameters:
        interval - the time interval
        Returns:
        the removed activities
      • getIntersectingObjects

        public final Collection<A> getIntersectingObjects​(TimeInterval interval)
        Returns all activities found within the given time interval.
        Parameters:
        interval - the time interval
        Returns:
        the found activities
      • getIntersectingObjects

        public final Collection<A> getIntersectingObjects​(long start,
                                                          long end)
        Returns all activities found within the given time interval.
        Parameters:
        start - the time interval start
        end - 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.