Class Gap<T extends Slot>

Type Parameters:
T - type of slots
All Implemented Interfaces:
IntervalLike, Comparable<IntervalLike>

public class Gap<T extends Slot> extends TimeInterval
Class representing a (possibly infinite) gap between at most two slots in a Sequence. A gap can be bounded by prevSlot() in the beginning and by nextSlot() in the end. Like any other TimeInterval, a gap has TimeInterval.beginTime(), TimeInterval.endTime() and TimeInterval.duration(). Both begin time and end time can be infinite. Gaps of negative duration are not allowed.
Author:
Andrey Malykhanov
See Also:
  • Constructor Details

    • Gap

      public Gap(Sequence<T> sequence, double beginTime, double endTime, T prevSlot, T nextSlot)
      Creates a new gap with the specified begin time, end time, begin slot and end slot.
      Parameters:
      sequence - sequence of slots to which this gap belongs
      beginTime - begin time of the gap, possibly a Double.NEGATIVE_INFINITY
      endTime - end time of the gap, possibly a Double.POSITIVE_INFINITY
      prevSlot - previous slot limiting this gap, possibly null
      nextSlot - next slot limiting this gap, possibly null
  • Method Details

    • dummy

      public static Gap<?> dummy(double time)
      Creates a dummy instance of Gap used primarily as a key in search and comparison methods.
      Parameters:
      time - time used as a search key
      Returns:
      dummy instance of Gap
    • sequence

      public Sequence<T> sequence()
      Returns the Sequence to which this gap belongs.
      Returns:
      Sequence to which this gap belongs
    • prevSlot

      public T prevSlot()
      Returns the slot limiting this gap from the left. Can be null if this gap is not limited from the left by any slot.
      Returns:
      reference to Slot limiting this gap from the left, or null
    • nextSlot

      public T nextSlot()
      Returns the slot limiting this gap from the right. Can be null if this gap is not limited from the right by any slot.
      Returns:
      reference to Slot limiting this gap from the right, or null
    • toString

      public String toString()
      Overrides:
      toString in class Interval
    • getIntersection

      public Gap<T> getIntersection(Slot slot)
      Returns the gap that is the result of intersecting this gap with the specified slot, or null if this gap does not intersect with the specified slot.
      Parameters:
      slot - specified slot
      Returns:
      gap that is the result of intersecting this gap with the specified slot, or null
    • getIntersection

      public Gap<T> getIntersection(Gap<?> gap)
      Returns the gap that is the result of intersecting this gap with the specified other gap, or null if this gap does not intersect with the specified other gap.
      Parameters:
      gap - specified other gap
      Returns:
      gap that is the result of intersecting this gap with the specified other gap, or null