Package org.yamcs.utils
Class PartitionedTimeInterval<T extends TimeInterval>
java.lang.Object
org.yamcs.utils.PartitionedTimeInterval<T>
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionget
(int i) getFit
(long t) returns an interval where t would fit or null if there is no such intervalInserts an interval in the list if it doesn't overlap with an existing one.Insert a new time interval in the list, if it doesn't overlap with the existing intervals.boolean
isEmpty()
iterator()
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
(TimeInterval timeInterval) Creates an iterator that iterates over all the timeintervals overlapping with timeInterval The timeInterval is considered closed at both ends [start, stop]int
size()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PartitionedTimeInterval
public PartitionedTimeInterval()
-
-
Method Details
-
insert
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
Inserts an interval in the list if it doesn't overlap with an existing one.- Returns:
- returns the interval inserted
-
overlappingIterator
Creates an iterator that iterates over all the timeintervals overlapping with timeInterval The timeInterval is considered closed at both ends [start, stop] -
overlappingReverseIterator
Creates an iterator that iterates over all the timeintervals overlapping with timeInterval The timeInterval is considered closed at both ends [start, stop] -
getFit
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
- Specified by:
iterator
in interfaceIterable<T extends TimeInterval>
-
reverseIterator
-
get
-
isEmpty
public boolean isEmpty()
-