Class MetroIIPtidesListEventQueue
- java.lang.Object
-
- ptolemy.domains.metroII.kernel.MetroIIPtidesListEventQueue
-
- All Implemented Interfaces:
DEEventQueue,Debuggable
public class MetroIIPtidesListEventQueue extends java.lang.Object implements DEEventQueue
Event queue that is a linked list. This provides a totally ordered sorted event queue. It also allows all events to be accessed in the order they are sorted.This is identical to PtidesListEventQueue except receivers are mapped to MetroIIPtidesReceiver.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Jia Zou, Liangpeng Guo
- Pt.AcceptedRating:
- Red (jiazou)
- Pt.ProposedRating:
- Red (jiazou)
-
-
Constructor Summary
Constructors Constructor Description MetroIIPtidesListEventQueue()Constructs an empty event queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDebugListener(DebugListener listener)Adds a debugger listen for this event queue.voidclear()Clears the event queue.PtidesEventget()Gets the smallest event from the event queue.PtidesEventget(int index)Gets the event from the event queue that is pointed by the index.booleanisEmpty()Checks if the event queue is empty.voidput(DEEvent event)Puts the event queue into the event queue, and then sort it by timestamp order.booleanremove(DEEvent event)Throw an exception to indicate that this method is not supported.voidremoveDebugListener(DebugListener listener)Removes the debugger listen for this event queue.intsize()Returns the size of this event queue.PtidesEventtake()Take this event and remove it from the event queue.PtidesEventtake(int index)Takes this event and remove it from the event queue.java.lang.Object[]toArray()Returns an array representation of this event queue.
-
-
-
Method Detail
-
clear
public void clear()
Clears the event queue.- Specified by:
clearin interfaceDEEventQueue
-
get
public PtidesEvent get() throws InvalidStateException
Gets the smallest event from the event queue.- Specified by:
getin interfaceDEEventQueue- Returns:
- a PtidesEvent object.
- Throws:
InvalidStateException- if the getFirst() method of the queue throws it.
-
get
public PtidesEvent get(int index) throws InvalidStateException
Gets the event from the event queue that is pointed by the index.- Parameters:
index- an int specifying the index.- Returns:
- a DEEvent object pointed to by the index.
- Throws:
InvalidStateException- if get() method of the queue throws it.
-
isEmpty
public boolean isEmpty()
Checks if the event queue is empty.- Specified by:
isEmptyin interfaceDEEventQueue- Returns:
- True if this queue is empty, false otherwise.
-
put
public void put(DEEvent event) throws IllegalActionException
Puts the event queue into the event queue, and then sort it by timestamp order.- Specified by:
putin interfaceDEEventQueue- Parameters:
event- a DEEvent object.- Throws:
IllegalActionException- if the addFirst() method of the queue throws it.
-
remove
public boolean remove(DEEvent event) throws IllegalActionException
Throw an exception to indicate that this method is not supported.- Specified by:
removein interfaceDEEventQueue- Parameters:
event- The event to enqueue.- Returns:
- In this class, this method never returns.
- Throws:
IllegalActionException- Always thrown.
-
size
public int size()
Returns the size of this event queue.- Specified by:
sizein interfaceDEEventQueue- Returns:
- The size of the event queue.
-
take
public PtidesEvent take() throws InvalidStateException
Take this event and remove it from the event queue. If the event is a DEEvent, then put the token of this event into the receiver.NOTE: this method should only be called once for each event in the event queue, unless the event is not a DEEvent. Because each time this method is called, the token associated with this event is transferred to the receiver. Also, the same event should not be taken out of the event queue and then put into the event queue multiple times.
- Specified by:
takein interfaceDEEventQueue- Returns:
- The event associated with this index in the event queue.
- Throws:
InvalidStateException
-
take
public PtidesEvent take(int index) throws InvalidStateException
Takes this event and remove it from the event queue. If the event is a DEEvent, then put the token of this event into the receiver.NOTE: this method should only be called once for each event in the event queue, unless the event is not a DEEvent. Because each time this method is called, the token associated with this event is transferred to the receiver. Also, the same event should not be taken out of the event queue and then put into the event queue multiple times.
- Parameters:
index- The index of this event in the event queue.- Returns:
- The event associated with this index in the event queue.
- Throws:
InvalidStateException
-
toArray
public java.lang.Object[] toArray()
Returns an array representation of this event queue.- Specified by:
toArrayin interfaceDEEventQueue- Returns:
- an array of Objects in the list.
-
addDebugListener
public void addDebugListener(DebugListener listener)
Adds a debugger listen for this event queue.- Specified by:
addDebugListenerin interfaceDebuggable- Parameters:
listener- The listener to which to send debug messages.- See Also:
removeDebugListener(ptolemy.kernel.util.DebugListener)
-
removeDebugListener
public void removeDebugListener(DebugListener listener)
Removes the debugger listen for this event queue.- Specified by:
removeDebugListenerin interfaceDebuggable- Parameters:
listener- The listener to remove from the list of listeners to which debug messages are sent.- See Also:
addDebugListener(ptolemy.kernel.util.DebugListener)
-
-