m865.simulation
Class Clock

java.lang.Object
  extended by m865.simulation.Clock

public class Clock
extends java.lang.Object

The Clock maintains a priority queue of Events. It also keeps track of the times and can be queried for the current time.


Field Summary
static int IMMEDIATE
          The time for any event which must occur immediately.
protected  PriorityQueueAL pq
          The prority queue for keeping track of the events
protected  int time
          The current time.
 
Constructor Summary
Clock()
          Constructor for the clock.
 
Method Summary
 void dumpSchedule()
          Dumps the schedule.
 boolean hasEvent()
          Determine if there are more events to be processed.
 Event nextEvent()
          Gets the next event.
 int now()
          Gets the current time.
 void remove(Event event)
          Removes the specified event from the priority queue.
 void schedule(Event event)
          Place the specified event into the schedule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMMEDIATE

public static final int IMMEDIATE
The time for any event which must occur immediately.

See Also:
Constant Field Values

pq

protected PriorityQueueAL pq
The prority queue for keeping track of the events


time

protected int time
The current time.

Constructor Detail

Clock

public Clock()
Constructor for the clock.

Method Detail

schedule

public void schedule(Event event)
Place the specified event into the schedule.

Parameters:
event - the Event to be scheduled.

hasEvent

public boolean hasEvent()
Determine if there are more events to be processed.

Returns:
true if there are more events in the priority queue.

nextEvent

public Event nextEvent()
Gets the next event.

Returns:
the next Event to be processed.

remove

public void remove(Event event)
Removes the specified event from the priority queue.

Parameters:
event - the Event to be removed.

now

public int now()
Gets the current time.

Returns:
the current time.

dumpSchedule

public void dumpSchedule()
Dumps the schedule.