SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | List of all members
EventList Interface Reference

An interface for implementations of event lists. More...

Inheritance diagram for EventList:
[legend]
Collaboration diagram for EventList:
[legend]

Public Member Functions

boolean isEmpty ()
 Returns true if and only if the event list is empty (no event is scheduled). More...
 
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...
 
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...
 
ListIterator< EventlistIterator ()
 Returns a list iterator over the elements of the class Event in this 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...
 

Detailed Description

An interface for implementations of event lists.

Different implementations are provided in SSJ: doubly-linked list, splay tree, Henricksen’s method, etc. The events in the event list are objects of the class umontreal.ssj.simevents.Event. The method umontreal.ssj.simevents.Sim.init(EventList) permits one to select the actual implementation used in a simulation [107] .

To allow the user to print the event list, the java.lang.Object.toString method from the Object class should be reimplemented in all EventList implementations. It will return a string in the following format: "<tt>Contents of the event list </tt><em>event list class</em><tt>:</tt>" for the first line and each subsequent line has format "<em>scheduled event time</em><tt>, </tt><em>event priority</em>&nbsp;<tt>:</tt>&nbsp;<em>event string</em>". The event string is obtained by calling the toString method of the event objects. The string should not end with the end-of-line character.

The following example is the event list of the bank example, printed at 10h30. See examples.pdf for more information.

Contents of the event list SplayTree:
   10.51,        1 : BankEv$Arrival@cfb549
   10.54,        1 : BankEv$Departure@8a7efd
      11,        1 : BankEv$3@86d4c1
      14,        1 : BankEv$4@f9f9d8
      15,        1 : BankEv$5@820dda

Member Function Documentation

◆ add()

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.

Parameters
evevent to be added

Implemented in Henriksen, SplayTree, RedblackTree, BinaryTree, and DoublyLinked.

◆ addAfter()

void addAfter ( Event  ev,
Event  other 
)

Same as add, but adds the new event ev immediately after the event other in the list.

Parameters
evevent to be added
otherreference event after which ev will be added

Implemented in SplayTree, BinaryTree, Henriksen, DoublyLinked, and RedblackTree.

◆ addBefore()

void addBefore ( Event  ev,
Event  other 
)

Same as add, but adds the new event ev immediately before the event other in the list.

Parameters
evevent to be added
otherreference event before which ev will be added

Implemented in SplayTree, Henriksen, BinaryTree, DoublyLinked, and RedblackTree.

◆ addFirst()

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.

Parameters
evevent to be added

Implemented in SplayTree, Henriksen, BinaryTree, DoublyLinked, and RedblackTree.

◆ getFirst()

Event getFirst ( )

Returns the first event in the event list.

If the event list is empty, returns null.

Returns
the first event in the event list, or null if the list is empty

Implemented in SplayTree, BinaryTree, Henriksen, DoublyLinked, and RedblackTree.

◆ getFirstOfClass() [1/2]

Event getFirstOfClass ( String  cl)

Returns the first event of the class cl (a subclass of Event) in the event list.

If no such event is found, returns null.

Returns
the first event of class cl, or null if no such event exists in the list

Implemented in SplayTree, BinaryTree, Henriksen, DoublyLinked, and RedblackTree.

◆ getFirstOfClass() [2/2]

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.

If no such event is found, returns null.

Returns
the first event of class cl, or null if no such event exists in the list

Implemented in SplayTree, BinaryTree, Henriksen, DoublyLinked, and RedblackTree.

◆ isEmpty()

boolean isEmpty ( )

Returns true if and only if the event list is empty (no event is scheduled).

Returns
true if the event list is empty

Implemented in RedblackTree, Henriksen, SplayTree, BinaryTree, and DoublyLinked.

◆ listIterator()

ListIterator<Event> listIterator ( )

Returns a list iterator over the elements of the class Event in this list.

Returns
a list iterator over the elements of the class Event in this list

Implemented in SplayTree, DoublyLinked, BinaryTree, Henriksen, and RedblackTree.

◆ remove()

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.

Parameters
evevent to be removed
Returns
true if the event was successfully removed from the list

Implemented in SplayTree, BinaryTree, Henriksen, DoublyLinked, and RedblackTree.

◆ removeFirst()

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.

Returns
the first event removed from the list, or null if the list is empty

Implemented in SplayTree, BinaryTree, Henriksen, DoublyLinked, and RedblackTree.


The documentation for this interface was generated from the following file: