| | |
-
- EventScheduleStack
class EventScheduleStack() |
| |
The class defines a schedule of events in a general discrete-event
simulation. It relies on the misclib.Stack class (but it does not
inherit from the Stack class).
EventScheduleStack is less efficient (=slower) than the heap-based
EventSchedule class but the two classes are otherwise equivalent in
principle. Since it uses the Stack class also for the event types,
and since all the methods of the list class are available via the
Stack class, EventScheduleStack may be used for creating subclasses
to this class which can handle more complex types of schedules than
those that can be handled by the dict-based EventSchedule.
An additional feature of EventScheduleStack is that it can handle TIES
perfectly (the dict-based EventSchedule only handles ties approximately). |
| |
Methods defined here:
- __init__(self, eventlist=[], timelist=[], sort=False)
- Creates two new stacks: one for the events and one for the corresponding
time points. The events could for instance be described by strings. The
times are (of course) floating-point numbers. The two stacks can be
filled here but they have to be synchronized and in temporal order.
- get_next_event(self)
- Method used to get the next stored event (the first in time) from the
event schedule. The synchronized stacks eventstack and timestack are
shifted in Perl fashion - i. e. the element that is returned is also
removed from the stack. Returns None if the stacks are empty.
- put_event(self, eventtype, eventtime)
- Method used to place an event in the event schedule. The event is placed
in temporal order in the synchronized stacks eventstack and timestack.
- show_next_event(self)
- Just look at the next event without touching the stack.
- zap_events(self)
- Method used to empty the schedule to allow for a restart.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |