Class 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)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDebugListener​(DebugListener listener)
      Adds a debugger listen for this event queue.
      void clear()
      Clears the event queue.
      PtidesEvent get()
      Gets the smallest event from the event queue.
      PtidesEvent get​(int index)
      Gets the event from the event queue that is pointed by the index.
      boolean isEmpty()
      Checks if the event queue is empty.
      void put​(DEEvent event)
      Puts 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)
      Removes 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)
      Takes this event and remove it from the event queue.
      java.lang.Object[] toArray()
      Returns 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

      • MetroIIPtidesListEventQueue

        public MetroIIPtidesListEventQueue()
        Constructs an empty event queue.
    • Method Detail

      • clear

        public void clear()
        Clears the event queue.
        Specified by:
        clear in interface DEEventQueue
      • 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:
        isEmpty in interface DEEventQueue
        Returns:
        True if this queue is empty, false otherwise.
      • 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
        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:
        toArray in interface DEEventQueue
        Returns:
        an array of Objects in the list.