Class PartitionedTimeInterval<T extends TimeInterval>

java.lang.Object
org.yamcs.utils.PartitionedTimeInterval<T>
All Implemented Interfaces:
Iterable<T>

public class PartitionedTimeInterval<T extends TimeInterval> extends Object implements Iterable<T>
A list of sorted, non overlapping TimeInterval

The 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 Details

    • PartitionedTimeInterval

      public PartitionedTimeInterval()
  • Method Details

    • 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()
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends TimeInterval>
    • reverseIterator

      public Iterator<T> reverseIterator()
    • get

      public TimeInterval get(int i)
    • isEmpty

      public boolean isEmpty()