SSJ  3.3.1
Stochastic Simulation in Java
Classes | Public Member Functions | Package Functions | Package Attributes | List of all members
DoublyLinked Class Reference

An implementation of EventList using a doubly linked linear list. More...

Inheritance diagram for DoublyLinked:
[legend]
Collaboration diagram for DoublyLinked:
[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...
 
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...
 
Iterator< Eventiterator ()
 
ListIterator< EventlistIterator ()
 Returns a list iterator over the elements of the class Event in this list. More...
 
String toString ()
 

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...
 

Package Attributes

Node last = null
 

Detailed Description

An implementation of EventList using a doubly linked linear list.

Each event is stored into a list node that contains a pointer to its following and preceding events. Adding an event requires a linear search to keep the event list sorted by event time and priority. Removing the first event is done in constant time because it simply removes the first list node. List nodes are recycled for increased memory management efficiency.

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

Implements EventList.

◆ 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

Implements EventList.

◆ 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

Implements EventList.

◆ 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

Implements EventList.

◆ 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

Implements EventList.

◆ 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

Implements EventList.

◆ getFirstOfClass() [2/2]

public<E extends Event> E getFirstOfClass ( Class< E >  cl)
package

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

Implements EventList.

◆ 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

Implements EventList.

◆ 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

Implements EventList.

◆ 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

Implements EventList.

◆ 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

Implements EventList.


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