Package com.amalgamasimulation.trains
Class BookingSequence
java.lang.Object
com.amalgamasimulation.core.scheduling.Sequence<BookingSlot>
com.amalgamasimulation.trains.BookingSequence
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
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBookingSlot(double atTime) Finds and returns theBookingSlotin the sequence that includes the specified point in time.voidinsert(double time, Sequence<? extends BookingSlot> insertedSequence) Method is not allowed.voidinsert(double time, BookingSlot slot) Inserts the specified slot into the specified time of this sequence.Methods inherited from class com.amalgamasimulation.core.scheduling.Sequence
allGapsBetween, allGapsIntersecting, allSlots, allSlotsBetween, allSlotsIntersecting, clear, copy, extend, firstGap, firstGapAfter, firstGapBeginTime, firstSlot, firstSlotAfter, firstSlotIndex, gaps, gapsListIterator, getSlotInsertionIndex, getSlotInsertionIndex, getSlotInsertionIndexInternal, insertLast, insertSlotInternal, lastGap, lastSlot, lastSlotBefore, moveForwardBy, moveForwardTo, moveRightSlotsInternal, remove, slot, slots, slotsAfter, slotsCount, subSequence, subSequence, toString, totalDuration
-
Constructor Details
-
BookingSequence
public BookingSequence()
-
-
Method Details
-
insert
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:
insertin classSequence<BookingSlot>- Parameters:
time- time of insertion. The slot's begin time will be changed to this timeslot- slot to be inserted
-
insert
Method is not allowed.- Overrides:
insertin classSequence<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
Finds and returns theBookingSlotin 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
BookingSlotthat includes the specified time, ornullif none is found
-