Class ReplayTimeline<E>

java.lang.Object
nz.ac.vuw.ecs.swen225.gp6.recorder.datastructures.ReplayTimeline<E>
Type Parameters:
E - the type of the events

public class ReplayTimeline<E> extends Object
A generic timeline class that replays a series of events in chronological order. Events can be retrieved in both forward and reverse order.
  • Constructor Details

    • ReplayTimeline

      public ReplayTimeline(RecordTimeline<E> recording)
      Creates a new Timeline.
      Parameters:
      recording - the recording to replay from a RecordTimeline object.
    • ReplayTimeline

      public ReplayTimeline(Stack<Pair<Long,E>> recording)
      Creates a new Timeline.
      Parameters:
      recording - the recording to replay from a stack of pairs.
  • Method Details

    • next

      public Pair<Long,E> next()
      Returns the next action in the timeline.
      Returns:
      returns the time and event of the next action.
    • hasNext

      public boolean hasNext()
      Checks if there are any more actions in the timeline.
      Returns:
      Whether there are more actions in the timeline.
    • peek

      public Pair<Long,E> peek()
      Returns the next action in the timeline without removing it.
      Returns:
      returns the time and event of the next action.
    • toString

      public String toString()
      Overrides:
      toString in class Object