Class ListEventQueue
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<SimEvent>, Collection<SimEvent>, List<SimEvent>, RandomAccess, SequencedCollection<SimEvent>, EventQueue
This class implements an event queue used internally by the Sim_system to
manage
the list of future and deferred Sim_events. It should not be needed in
a user simulation. It works like a normal FIFO
queue, but during insertion events are kept in order from the smallest time
stamp to the largest. This means the next event to occur will be at the top
of the queue. <P>
The current implementation
is uses a Vector to store the queue and is inefficient for popping
and inserting elements because the rest of the array has to be
moved down one space. A better method would be to use a circular array.
- See Also:
-
Field Summary
Fields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionAllocates a new EventQueue object.ListEventQueue(int initialCapacity) Allocates a new EventQueue object, with an initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd a new event to the queue, preserving the temporal order of the events in the queue.peek()Method peek.pop()Remove and return the event at the top of the queue.booleanRemoves given eventtop()Return the event at the top of the queue, without removing it.Methods inherited from class ArrayList
add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class AbstractCollection
containsAll, toStringMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface EventQueue
clear, iterator, sizeMethods inherited from interface List
containsAll, reversed
-
Constructor Details
-
ListEventQueue
public ListEventQueue()Allocates a new EventQueue object. -
ListEventQueue
public ListEventQueue(int initialCapacity) Allocates a new EventQueue object, with an initial capacity.- Parameters:
initialCapacity- The initial capacity of the queue.
-
-
Method Details
-
pop
Remove and return the event at the top of the queue.- Specified by:
popin interfaceEventQueue- Returns:
- The next event.
-
top
Return the event at the top of the queue, without removing it.- Returns:
- The next event.
-
add
Add a new event to the queue, preserving the temporal order of the events in the queue.- Specified by:
addin interfaceCollection<SimEvent>- Specified by:
addin interfaceEventQueue- Specified by:
addin interfaceList<SimEvent>- Overrides:
addin classArrayList<SimEvent>- Parameters:
new_event- The event to be put on the queue.- Returns:
- true if the operation is successful, false otherwise
-
peek
Description copied from interface:EventQueueMethod peek.- Specified by:
peekin interfaceEventQueue- Returns:
- the first event of the queue, without removing it
-
remove
Description copied from interface:EventQueueRemoves given event- Specified by:
removein interfaceEventQueue- Parameters:
ev- the event to remove- Returns:
- true if event was found, false otherwise
-