Class 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
      void addDebugListener​(DebugListener listener)
      Add a debugger listen for this event queue.
      void clear()
      Clear the event queue.
      PtidesEvent get()
      Get the smallest event from the event queue.
      PtidesEvent get​(int index)
      Get the event from the event queue that is pointed by the index.
      boolean isEmpty()
      Check if the event queue is empty.
      void put​(DEEvent event)
      Put the event queue into the event queue, and then sort it by timestamp order.
      boolean remove​(DEEvent event)
      Throw an exception to indicate that this method is not supported.
      void removeDebugListener​(DebugListener listener)
      Remove the debugger listen for this event queue.
      int size()
      Returns the size of this event queue.
      PtidesEvent take()
      Take this event and remove it from the event queue.
      PtidesEvent take​(int index)
      Take this event and remove it from the event queue.
      java.lang.Object[] toArray()
      Return an array representation of this event queue.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PtidesListEventQueue

        public PtidesListEventQueue()
        Construct an empty event queue.
    • Method Detail

      • clear

        public void clear()
        Clear the event queue.
        Specified by:
        clear in interface DEEventQueue
      • 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:
        isEmpty in interface DEEventQueue
        Returns:
        True if this queue is empty, false otherwise.
      • remove

        public boolean remove​(DEEvent event)
                       throws IllegalActionException
        Throw an exception to indicate that this method is not supported.
        Specified by:
        remove in interface DEEventQueue
        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:
        size in interface DEEventQueue
        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:
        take in interface DEEventQueue
        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:
        toArray in interface DEEventQueue
        Returns:
        an array of Objects in the list.