Interface MessageQueue<T>

  • Type Parameters:
    T -
    All Superinterfaces:
    java.lang.Iterable<T>
    All Known Subinterfaces:
    SipMessageQueue

    public interface MessageQueue<T>
    extends java.lang.Iterable<T>
    Interface for message queue.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean add​(T e)
      Adds an element to the end of the queue.
      void addFirst​(T e)
      Add an element to the start of the queue.
      void clear()
      Removes all of the elements from this queue.
      T element()
      Retrieves, but does not remove, the head of this queue.
      boolean isEmpty()
      Determines if queue is empty.
      boolean offer​(T e)
      Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
      T peek()
      Retrieves , but does not remove, the head of this queue, or returns null if this queue is empty.
      T peekLast()
      Retrieves , but does not remove, the last element of this queue, or returns null if this queue is empty.
      T poll()
      Retrieves and removes the head of this queue, or returns null if this queue is empty.
      T remove()
      Retrieves and removes the head of this queue.
      int size()
      Returns the number of elements in this collection.
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • Method Detail

      • add

        boolean add​(T e)
        Adds an element to the end of the queue.
        Parameters:
        e - the element to add, not null.
        Throws:
        java.lang.NullPointerException - if the specified element is null
      • offer

        boolean offer​(T e)
        Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to add(T), which can fail to insert an element only by throwing an exception.
        Parameters:
        e - the element to add
        Returns:
        true if the element was added to this queue, else false
        Throws:
        java.lang.ClassCastException - if the class of the specified element prevents it from being added to this queue
        java.lang.NullPointerException - if the specified element is null and this queue does not permit null elements
        java.lang.IllegalArgumentException - if some property of this element prevents it from being added to this queue
      • peek

        T peek()
        Retrieves , but does not remove, the head of this queue, or returns null if this queue is empty.
        Returns:
        head of queue, or null if empty queue.
      • addFirst

        void addFirst​(T e)
        Add an element to the start of the queue.
        Parameters:
        e - the message to add, not null.
        Throws:
        java.lang.NullPointerException - if the specified element is null
      • peekLast

        T peekLast()
        Retrieves , but does not remove, the last element of this queue, or returns null if this queue is empty.
        Returns:
        last element of queue, or null if empty queue.
      • clear

        void clear()
        Removes all of the elements from this queue.
      • isEmpty

        boolean isEmpty()
        Determines if queue is empty.
        Returns:
        true if queue is empty.
      • remove

        T remove()
        Retrieves and removes the head of this queue. This method differs from poll only in that it throws an exception if this queue is empty.
        Returns:
        the head of this queue
        Throws:
        java.util.NoSuchElementException - if this queue is empty
      • poll

        T poll()
        Retrieves and removes the head of this queue, or returns null if this queue is empty.
        Returns:
        the head of this queue, or null if this queue is empty
      • element

        T element()
        Retrieves, but does not remove, the head of this queue. This method differs from peek only in that it throws an exception if this queue is empty.
        Returns:
        the head of this queue
        Throws:
        java.util.NoSuchElementException - if this queue is empty
      • size

        int size()
        Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Returns:
        the number of elements in this collection