Class CircularEventQueue
java.lang.Object
simEngine.CircularEventQueue
- All Implemented Interfaces:
Iterable<SimEvent>, EventQueue
This class implements an event queue used internally by the Sim_system to
manage the list of Sim_events.
- Version:
- 7-ott-2003 14.50.16
- Author:
- Federico Granata
-
Constructor Summary
ConstructorsConstructorDescriptionAllocates a new EventQueue object.CircularEventQueue(int initialCapacity) Allocates a new EventQueue object, with an initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanAdd a new event to the queue, preserving the temporal order of the events in the queue.voidclear()clears the queue of all its elementselements()Returns an enumeration of the components of this vector.iterator()Returns an iterator that iterates over this queue elements in no special order.peek()Method peek.final SimEventpop()Remove and return the event at the top of the queue.booleanRemoves given eventbooleanremoveElement(SimEvent event) removes the selected elementfinal intsize()Returns the number of components in this vector.static voidtest()final SimEventtop()Return the event at the top of the queue, without removing it.toString()Returns a string representation of the object.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
CircularEventQueue
public CircularEventQueue(int initialCapacity) Allocates a new EventQueue object, with an initial capacity.- Parameters:
initialCapacity- The initial capacity of the queue.
-
CircularEventQueue
public CircularEventQueue()Allocates a new EventQueue object.
-
-
Method Details
-
size
public final int size()Returns the number of components in this vector.- Specified by:
sizein interfaceEventQueue- Returns:
- the number of components in this vector.
-
add
Add a new event to the queue, preserving the temporal order of the events in the queue.- Specified by:
addin interfaceEventQueue- Parameters:
new_event- The event to be put on the queue.- Returns:
- true if element was added, false otherwise.
-
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.
-
removeElement
removes the selected element- Parameters:
event-- Returns:
- true if the operation is successful, false otherwise
-
clear
public void clear()clears the queue of all its elements- Specified by:
clearin interfaceEventQueue
-
elements
Returns an enumeration of the components of this vector. The returnedEnumerationobject will generate all items in this vector. The first item generated is the item at index0, then the item at index1, and so on.- Returns:
- an enumeration of the components of this vector.
- See Also:
-
toString
Returns a string representation of the object. In general, thetoStringmethod returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.The
toStringmethod for classObjectreturns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:getClass().getName() + '@' + Integer.toHexString(hashCode())
-
test
public static void test() -
iterator
Description copied from interface:EventQueueReturns an iterator that iterates over this queue elements in no special order. Iterator must implement remove() method.- Specified by:
iteratorin interfaceEventQueue- Specified by:
iteratorin interfaceIterable<SimEvent>- Returns:
- an iterator with no special order.
-
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
-