Class PartitionedTimeInterval<T extends TimeInterval>

  • All Implemented Interfaces:
    Iterable<T>

    public class PartitionedTimeInterval<T extends TimeInterval>
    extends Object
    implements Iterable<T>
    A list of sorted, non overlapping TimeInterval The composing time intervals are considered closed at start and open at end [start, end)

    It is implemented as a copy on write array and it is thread safe.

    • Constructor Detail

      • PartitionedTimeInterval

        public PartitionedTimeInterval()
    • Method Detail

      • insert

        public T insert​(T x,
                        long tolerance)
        Insert a new time interval in the list, if it doesn't overlap with the existing intervals. If it overlaps but the overlap is within the tolerance (on either end), it modifies it such as to fit perfectly If it overlaps and the overlap is not within the tolerance margin, then it doesn't do anything and it returns null; This operation assumes that the lengths of the interval is at least twice the tolerance.
        Returns:
        returns the possibly modified inserted interval
      • insert

        public T insert​(T timeInterval)
        Inserts an interval in the list if it doesn't overlap with an existing one.
        Returns:
        returns the interval inserted
      • overlappingIterator

        public Iterator<T> overlappingIterator​(TimeInterval timeInterval)
        Creates an iterator that iterates over all the timeintervals overlapping with timeInterval The timeInterval is considered closed at both ends [start, stop]
      • overlappingReverseIterator

        public Iterator<T> overlappingReverseIterator​(TimeInterval timeInterval)
        Creates an iterator that iterates over all the timeintervals overlapping with timeInterval The timeInterval is considered closed at both ends [start, stop]
      • getFit

        public T getFit​(long t)
        returns an interval where t would fit or null if there is no such interval
        Returns:
        ti such that ti.getStart() <= t < ti.getEnd()
      • size

        public int size()
      • reverseIterator

        public Iterator<T> reverseIterator()