com.cogent
Class SimEventQueue

java.lang.Object
  |
  +--com.cogent.SimEventQueue

public class SimEventQueue
extends java.lang.Object

The event queue contains a MinHeap to implement a priority queue. It handles adding events, dequeing events, and dequeing all events with the next priority level.


Constructor Summary
SimEventQueue()
          Constructor, creates an empty EventQueue
 
Method Summary
 SimEvent dequeue()
          Remove and return the next item from the priority queue.
 java.util.Vector dequeueNextPriorityLevel()
          This method returns a vector of all events that occur with the next lowest priority, removing them all from the queue
 void enqueue(SimEvent argEvent, long argPriority)
          Adds a single event to the event queue with the given priority
 boolean isEmpty()
          Returns whether the queue has more elements or not
 SimEvent peek()
          Return the next element in the queue by priority without removing it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimEventQueue

public SimEventQueue()
Constructor, creates an empty EventQueue

Method Detail

enqueue

public void enqueue(SimEvent argEvent,
                    long argPriority)
Adds a single event to the event queue with the given priority

Parameters:
argEvent - Event to add to the queue
argPriority - Priority (time) to add item with

dequeue

public SimEvent dequeue()
Remove and return the next item from the priority queue.

Returns:
The next priority element in the queue

peek

public SimEvent peek()
Return the next element in the queue by priority without removing it

Returns:
The next priority element in the queue

isEmpty

public boolean isEmpty()
Returns whether the queue has more elements or not

Returns:
The queue is empty or not

dequeueNextPriorityLevel

public java.util.Vector dequeueNextPriorityLevel()
This method returns a vector of all events that occur with the next lowest priority, removing them all from the queue

Returns:
A vector containing all events in the queue with the next lowest priority