Class CircularEventQueue

java.lang.Object
simEngine.CircularEventQueue
All Implemented Interfaces:
Iterable<SimEvent>, EventQueue

public class CircularEventQueue extends Object implements EventQueue
This class implements an event queue used internally by the Sim_system to manage the list of Sim_events.
Version:
7-ott-2003 14.50.16
Author:
Federico Granata
  • Constructor Details

    • CircularEventQueue

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

      public CircularEventQueue()
      Allocates a new EventQueue object.
  • Method Details

    • size

      public final int size()
      Returns the number of components in this vector.
      Specified by:
      size in interface EventQueue
      Returns:
      the number of components in this vector.
    • add

      public final 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 EventQueue
      Parameters:
      new_event - The event to be put on the queue.
      Returns:
      true if element was added, false otherwise.
    • pop

      public final 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 final SimEvent top()
      Return the event at the top of the queue, without removing it.
      Returns:
      The next event.
    • removeElement

      public boolean removeElement(SimEvent event)
      removes the selected element
      Parameters:
      event -
      Returns:
      true if the operation is successful, false otherwise
    • clear

      public void clear()
      clears the queue of all its elements
      Specified by:
      clear in interface EventQueue
    • elements

      public Enumeration<SimEvent> elements()
      Returns an enumeration of the components of this vector. The returned Enumeration object will generate all items in this vector. The first item generated is the item at index 0, then the item at index 1, and so on.
      Returns:
      an enumeration of the components of this vector.
      See Also:
    • toString

      public String toString()
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

      The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

      getClass().getName() + '@' + Integer.toHexString(hashCode())
      
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.
    • test

      public static void test()
    • iterator

      public Iterator<SimEvent> iterator()
      Description copied from interface: EventQueue
      Returns an iterator that iterates over this queue elements in no special order. Iterator must implement remove() method.
      Specified by:
      iterator in interface EventQueue
      Specified by:
      iterator in interface Iterable<SimEvent>
      Returns:
      an iterator with no special order.
    • 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