Class AndTimeIntervalsIteratorReversed

java.lang.Object
com.amalgamasimulation.core.scheduling.AndTimeIntervalsIteratorReversed
All Implemented Interfaces:
Iterator<Interval>

public class AndTimeIntervalsIteratorReversed extends Object implements Iterator<Interval>
Iterator that combines several list iterators over time intervals (instances of Interval class) and iterates over the intersection of time intervals, one from each iterator in the list of iterators provided. The iteration is directed backward, i.e. the intervals returned by this iterator are sorted by beginTime in descending order, starting from the interval with the biggest beginTime value.

Time intervals in each one of the provided list iterators must not intersect inside the same iterator and must be sorted by beginTime in ascending order. Note that these conditions are not checked and, if they are not satisfied, this class can work incorrectly.

This class is especially useful when it is required to find a time interval satisfying certain conditions (for example, with duration not less than some value) in big or potentially infinite sequence of time intervals where, for example, several resources are available simultaneously. This class does not waste computational resources for creating actual list of candidate time intervals, rather calculating them on-the-fly.

Author:
Andrey Malykhanov
See Also:
  • Constructor Details

    • AndTimeIntervalsIteratorReversed

      public AndTimeIntervalsIteratorReversed(List<ListIterator<? extends Interval>> iterators)
      Creates an instance of the reverse iterator over the intersection time intervals, one from each iterator in the list of iterators provided.
      Parameters:
      iterators - list of list iterators (instances of ListIterator) over intervals
  • Method Details