Class EventQueue

java.lang.Object
  |
  +--EventQueue

public class EventQueue
extends java.lang.Object

An EventQueue maintains a queue of events in scheduled time order. An EventQueue also keeps track of time. When created, its current time is set to 0. Each time an event is removed, its current time is updated to the scheduled time for the removed event.


Constructor Summary
EventQueue()
          new EventQueue() returns an empty EventQueue.
 
Method Summary
 int getCurrentTime()
          eq.getCurrentTime() returns the current time for eq.
 int getEventCount()
          eq.getEventCount() returns the number of events in eq.
 NetEvent getNextEvent()
          eq.getNextEvent() removes and returns the event with the earliest scheduled time in eq.
 void schedule(NetEvent e, int tm)
          eq.schedule(e, tm) schedules e at time tm in eq.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventQueue

public EventQueue()
new EventQueue() returns an empty EventQueue.

Method Detail

getEventCount

public int getEventCount()
eq.getEventCount() returns the number of events in eq.


getNextEvent

public NetEvent getNextEvent()
eq.getNextEvent() removes and returns the event with the earliest scheduled time in eq. The current time for eq is updated to the scheduled time for the returned event.

Precondition: eq.getEventCount() > 0


schedule

public void schedule(NetEvent e,
                     int tm)
eq.schedule(e, tm) schedules e at time tm in eq.


getCurrentTime

public int getCurrentTime()
eq.getCurrentTime() returns the current time for eq. When eq is created its current time is 0. After NetEvents have been added and removed from eq, its current time is the scheduled time for its most recently removed event.