Class BookingSequence

java.lang.Object
com.amalgamasimulation.core.scheduling.Sequence<BookingSlot>
com.amalgamasimulation.trains.BookingSequence

public class BookingSequence extends Sequence<BookingSlot>
A class representing a sequence of BookingSlot. It is used to display the booking schedule over time. Unlike Sequence, this class does not allow shifting slots to the right along the time axis; instead, slots that have an intersection are merged into one. If merging is not possible, an exception is thrown.
Author:
Andrey Korotin
  • Constructor Details

    • BookingSequence

      public BookingSequence()
  • Method Details

    • insert

      public void insert(double time, BookingSlot slot)
      Inserts the specified slot into the specified time of this sequence. Shifting slots to the right along the time axis is not allowed; instead, slots that have an intersection are merged into one. If merging is not possible, an exception is thrown.
      Overrides:
      insert in class Sequence<BookingSlot>
      Parameters:
      time - time of insertion. The slot's begin time will be changed to this time
      slot - slot to be inserted
    • insert

      public void insert(double time, Sequence<? extends BookingSlot> insertedSequence)
      Method is not allowed.
      Overrides:
      insert in class Sequence<BookingSlot>
      Parameters:
      time - time of insertion. The begin of the first slot of the specified sequence will be changed to this time.
      insertedSequence - sequence of slots that is being inserted
    • getBookingSlot

      public BookingSlot getBookingSlot(double atTime)
      Finds and returns the BookingSlot in the sequence that includes the specified point in time.

      If no such slot exists, this method returns null.

      Parameters:
      atTime - the point in time
      Returns:
      the BookingSlot that includes the specified time, or null if none is found