Class ListEventQueue

All Implemented Interfaces:
Serializable, Cloneable, Iterable<SimEvent>, Collection<SimEvent>, List<SimEvent>, RandomAccess, SequencedCollection<SimEvent>, EventQueue

public class ListEventQueue extends ArrayList<SimEvent> implements EventQueue
This class implements an event queue used internally by the Sim_system to manage the list of future and deferred Sim_events. It should not be needed in a user simulation. It works like a normal FIFO queue, but during insertion events are kept in order from the smallest time stamp to the largest. This means the next event to occur will be at the top of the queue. <P> The current implementation is uses a Vector to store the queue and is inefficient for popping and inserting elements because the rest of the array has to be moved down one space. A better method would be to use a circular array.
See Also:
  • Constructor Details

    • ListEventQueue

      public ListEventQueue()
      Allocates a new EventQueue object.
    • ListEventQueue

      public ListEventQueue(int initialCapacity)
      Allocates a new EventQueue object, with an initial capacity.
      Parameters:
      initialCapacity - The initial capacity of the queue.
  • Method Details

    • pop

      public SimEvent pop()
      Remove and return the event at the top of the queue.
      Specified by:
      pop in interface EventQueue
      Returns:
      The next event.
    • top

      public SimEvent top()
      Return the event at the top of the queue, without removing it.
      Returns:
      The next event.
    • add

      public boolean add(SimEvent new_event)
      Add a new event to the queue, preserving the temporal order of the events in the queue.
      Specified by:
      add in interface Collection<SimEvent>
      Specified by:
      add in interface EventQueue
      Specified by:
      add in interface List<SimEvent>
      Overrides:
      add in class ArrayList<SimEvent>
      Parameters:
      new_event - The event to be put on the queue.
      Returns:
      true if the operation is successful, false otherwise
    • peek

      public SimEvent peek()
      Description copied from interface: EventQueue
      Method peek.
      Specified by:
      peek in interface EventQueue
      Returns:
      the first event of the queue, without removing it
    • remove

      public boolean remove(SimEvent ev)
      Description copied from interface: EventQueue
      Removes given event
      Specified by:
      remove in interface EventQueue
      Parameters:
      ev - the event to remove
      Returns:
      true if event was found, false otherwise