Class AndTimeIntervalsIterator

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

public class AndTimeIntervalsIterator extends Object implements Iterator<Interval>
Iterator that combines several 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 forward, i.e. the intervals returned by this iterator are sorted by beginTime in ascending order.

Time intervals in each one of the provided 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

    • AndTimeIntervalsIterator

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