|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object umontreal.iro.lecuyer.simevents.eventlist.RedblackTree
public class RedblackTree
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.
Constructor Summary | |
---|---|
RedblackTree()
|
Method Summary | ||
---|---|---|
void |
add(Event ev)
Adds a new event in the event list, according to the time of ev. |
|
void |
addAfter(Event ev,
Event other)
Same as add , but adds the new event ev
immediately after the event other in the list. |
|
void |
addBefore(Event ev,
Event other)
Same as add , but adds the new event ev
immediately before the event other in the list. |
|
void |
addFirst(Event ev)
Adds a new event at the beginning of the event list. |
|
void |
clear()
Empties the event list, i.e., cancels all events. |
|
Event |
getFirst()
Returns the first event in the event list. |
|
|
getFirstOfClass(Class<E> cl)
Returns the first event of the class E (a subclass of Event) in the event list. |
|
Event |
getFirstOfClass(String cl)
Returns the first event of the class cl (a subclass of Event) in the event list. |
|
boolean |
isEmpty()
Returns true if and only if the event list is empty (no event is scheduled). |
|
Iterator<Event> |
iterator()
|
|
ListIterator<Event> |
listIterator()
Returns a list iterator over the elements of the class Event in this list. |
|
boolean |
remove(Event ev)
Removes the event ev from the event list (cancels this event). |
|
Event |
removeFirst()
Removes the first event from the event list (to cancel or execute this event). |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RedblackTree()
Method Detail |
---|
public void clear()
EventList
clear
in interface EventList
public void add(Event ev)
EventList
add
in interface EventList
ev
- event to be addedpublic void addFirst(Event ev)
EventList
addFirst
in interface EventList
ev
- event to be addedpublic void addBefore(Event ev, Event other)
EventList
add
, but adds the new event ev
immediately before the event other in the list.
addBefore
in interface EventList
ev
- event to be addedother
- reference event before which ev will be addedpublic void addAfter(Event ev, Event other)
EventList
add
, but adds the new event ev
immediately after the event other in the list.
addAfter
in interface EventList
ev
- event to be addedother
- reference event after which ev will be addedpublic Event getFirst()
EventList
getFirst
in interface EventList
public Event getFirstOfClass(String cl)
EventList
getFirstOfClass
in interface EventList
public <E extends Event> E getFirstOfClass(Class<E> cl)
EventList
getFirstOfClass
in interface EventList
public boolean remove(Event ev)
EventList
remove
in interface EventList
ev
- event to be removed
public Event removeFirst()
EventList
removeFirst
in interface EventList
public String toString()
toString
in class Object
public Iterator<Event> iterator()
iterator
in interface Iterable<Event>
public ListIterator<Event> listIterator()
EventList
listIterator
in interface EventList
public boolean isEmpty()
EventList
isEmpty
in interface EventList
|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |