|
SSJ
3.3.1
Stochastic Simulation in Java
|
An implementation of EventList using a red black tree, which is similar to a binary search tree except that every node is colored red or black. More...
Public Member Functions | |
| void | clear () |
| Empties the event list, i.e., cancels all events. | |
| void | add (Event ev) |
Adds a new event in the event list, according to the time of ev. More... | |
| void | addFirst (Event ev) |
| Adds a new event at the beginning of the event list. More... | |
| void | addBefore (Event ev, Event other) |
Same as add, but adds the new event ev immediately before the event other in the list. More... | |
| void | addAfter (Event ev, Event other) |
Same as add, but adds the new event ev immediately after the event other in the list. More... | |
| Event | getFirst () |
| Returns the first event in the event list. More... | |
| Event | getFirstOfClass (String cl) |
Returns the first event of the class cl (a subclass of Event) in the event list. More... | |
| boolean | remove (Event ev) |
Removes the event ev from the event list (cancels this event). More... | |
| Event | removeFirst () |
| Removes the first event from the event list (to cancel or execute this event). More... | |
| String | toString () |
| Iterator< Event > | iterator () |
| ListIterator< Event > | listIterator () |
Returns a list iterator over the elements of the class Event in this list. More... | |
| boolean | isEmpty () |
Returns true if and only if the event list is empty (no event is scheduled). More... | |
Package Functions | |
| public< E extends Event > E | getFirstOfClass (Class< E > cl) |
Returns the first event of the class E (a subclass of Event) in the event list. More... | |
An implementation of EventList using a red black tree, which is similar to a binary search tree except that every node is colored red or black.
When modifying the structure, the tree is reorganized for the colors to satisfy rules that give an average \(O(\log(n))\) time for removing the first event or inserting a new event, where \(n\) is the number of elements in the structure. However, adding or removing events imply reorganizing the tree and requires more overhead than a binary search tree.
The present implementation uses the Java 2 TreeMap class which implements a red black tree for general usage. This event list implementation is not efficient.
| void add | ( | Event | ev | ) |
Adds a new event in the event list, according to the time of ev.
If the event list contains events scheduled to happen at the same time as ev, ev must be added after all these events.
| ev | event to be added |
Implements EventList.
| void addFirst | ( | Event | ev | ) |
Adds a new event at the beginning of the event list.
The given event ev will occur at the current simulation time.
| ev | event to be added |
Implements EventList.
| Event getFirst | ( | ) |
Returns the first event in the event list.
If the event list is empty, returns null.
null if the list is empty Implements EventList.
| Event getFirstOfClass | ( | String | cl | ) |
|
package |
| boolean isEmpty | ( | ) |
Returns true if and only if the event list is empty (no event is scheduled).
true if the event list is empty Implements EventList.
| ListIterator<Event> listIterator | ( | ) |
| boolean remove | ( | Event | ev | ) |
Removes the event ev from the event list (cancels this event).
Returns true if and only if the event removal has succeeded.
| ev | event to be removed |
true if the event was successfully removed from the list Implements EventList.
| Event removeFirst | ( | ) |
Removes the first event from the event list (to cancel or execute this event).
Returns the removed event. If the list is empty, then null is returned.
null if the list is empty Implements EventList.
1.8.14