hades.simulator
Class EventList

java.lang.Object
  extended byhades.simulator.EventList

public final class EventList
extends java.lang.Object

EventList: time-sorted doubly-linked list for discrete-event simulation.


Nested Class Summary
(package private)  class EventList.EventNode
          EventNode: one node of the simulation event list.
 
Field Summary
static boolean debug
           
(package private)  boolean enable_recycling
           
 long n_available
           
 long n_created
           
 long n_recycled
           
 
Constructor Summary
EventList()
          constructor for an empty event list.
 
Method Summary
 boolean delete(EventList.EventNode victim)
          delete node 'victim' from the list.
 void deleteAllEventsFromSource(SimObject source)
           
 void deleteFirst()
          delete the first node from the list.
 void first()
          set the cursor to the first node of this list
 SimEvent getData()
          get the current SimEvent (the data at the cursor EventNode)
 java.lang.String getName()
           
 EventList.EventNode getRecycledNode(SimEvent event)
           
 double getSecondEventTime()
           
 double getSimTime()
          get simulation time of the cursor node
 void insert(SimEvent event)
          insert a new SimEvent into the list at the position corresponding to its simulation time.
 boolean isEmpty()
          is this list empty?
 void last()
          set the cursor to the last node of this list
static void main(java.lang.String[] argv)
          main(): simple self test
static void message(java.lang.String msg)
           
 void next()
          move the cursor to the next node, if any
 void prev()
          move the cursor to the previous node, if any
 java.lang.String printStatus()
           
 void recycleNode(EventList.EventNode victim)
          recycle an EventNode for later reuse.
 void setName(java.lang.String name)
           
 void setSimTime(double t)
          set simulation time of the cursor node
 java.lang.String toString()
          Print the list.
static void usage()
          usage(): how to use the EventList selftest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static boolean debug

n_created

public long n_created

n_recycled

public long n_recycled

n_available

public long n_available

enable_recycling

boolean enable_recycling
Constructor Detail

EventList

public EventList()
constructor for an empty event list.

We query the following system/user properties to enable/disable event node recycling, and the recycle-stack capacity: "Hades.Simulator.EventList.EnableRecycling" (default "true") "Hades.Simulator.EventList.RecycleCapacity" (default 500)

Method Detail

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

first

public final void first()
set the cursor to the first node of this list


last

public final void last()
set the cursor to the last node of this list


next

public final void next()
move the cursor to the next node, if any


prev

public final void prev()
move the cursor to the previous node, if any


getSimTime

public final double getSimTime()
get simulation time of the cursor node


setSimTime

public final void setSimTime(double t)
set simulation time of the cursor node


getSecondEventTime

public final double getSecondEventTime()

getData

public final SimEvent getData()
get the current SimEvent (the data at the cursor EventNode)


getRecycledNode

public EventList.EventNode getRecycledNode(SimEvent event)

recycleNode

public void recycleNode(EventList.EventNode victim)
recycle an EventNode for later reuse. However, there is no need to keep to many nodes: the garbage collector will take care of every EventNode not handled by us.


printStatus

public java.lang.String printStatus()

insert

public final void insert(SimEvent event)
insert a new SimEvent into the list at the position corresponding to its simulation time.

Because most simulation events will be scheduled near the end of the event list, we start searching from the end.


deleteFirst

public final void deleteFirst()
delete the first node from the list. This is used after the corresponding simulation time is reached and processed.


delete

public final boolean delete(EventList.EventNode victim)
delete node 'victim' from the list. Warning: to avoid inconsistent data structures, this method removes the victim node from the list, but it is not allowed to recycle it. Please make sure that the calling method recycles the victim node, if this method returned 'true'.


toString

public java.lang.String toString()
Print the list.


isEmpty

public final boolean isEmpty()
is this list empty?


deleteAllEventsFromSource

public void deleteAllEventsFromSource(SimObject source)

message

public static void message(java.lang.String msg)

usage

public static void usage()
usage(): how to use the EventList selftest


main

public static void main(java.lang.String[] argv)
main(): simple self test