Class HybridEventQueue

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

public class HybridEventQueue extends Object implements EventQueue

Name: HybridEventQueue

Description: An hybrid implementation for the EventQueue interface. Future events are inserted and retrieved in a sorted binary heap with log(n) performances, while events for the current time interval are inserted and retrieved using an unbounded circular list.

Date: 12/mag/2009 Time: 18:40:26

Version:
1.1
Author:
Bertoli Marco
  • Constructor Details

    • HybridEventQueue

      public HybridEventQueue()
  • Method Details

    • add

      public boolean add(SimEvent event)
      Description copied from interface: EventQueue
      Adds an event to the queue
      Specified by:
      add in interface EventQueue
      Parameters:
      event - the event to add
      Returns:
      true if element was added, false otherwise.
    • clear

      public void clear()
      Description copied from interface: EventQueue
      Clears this queue, removing all pointers
      Specified by:
      clear in interface EventQueue
    • 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
    • pop

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

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

      public int size()
      Description copied from interface: EventQueue
      Method size.
      Specified by:
      size in interface EventQueue
      Returns:
      the number of events in this queue