Package ptolemy.domains.ptides.kernel
Class PtidesListEventQueue
- java.lang.Object
-
- ptolemy.domains.ptides.kernel.PtidesListEventQueue
-
- All Implemented Interfaces:
DEEventQueue,Debuggable
public class PtidesListEventQueue 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.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Jia Zou
- Pt.AcceptedRating:
- Red (jiazou)
- Pt.ProposedRating:
- Red (jiazou)
-
-
Constructor Summary
Constructors Constructor Description PtidesListEventQueue()Construct an empty event queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDebugListener(DebugListener listener)Add a debugger listen for this event queue.voidclear()Clear the event queue.PtidesEventget()Get the smallest event from the event queue.PtidesEventget(int index)Get the event from the event queue that is pointed by the index.booleanisEmpty()Check if the event queue is empty.voidput(DEEvent event)Put 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)Remove 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)Take this event and remove it from the event queue.java.lang.Object[]toArray()Return an array representation of this event queue.
-
-
-
Method Detail
-
clear
public void clear()
Clear the event queue.- Specified by:
clearin interfaceDEEventQueue
-
get
public PtidesEvent get() throws InvalidStateException
Get 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
Get 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()
Check 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
Put 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:
- True If a match is found and the entry is removed.
- 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
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.
- 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()
Return 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)
Add 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)
Remove 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)
-
-