Class PriorityQueues.SynchronizedPriorityQueue<K>

  • All Implemented Interfaces:
    PriorityQueue<K>, java.io.Serializable
    Enclosing class:
    PriorityQueues

    public static class PriorityQueues.SynchronizedPriorityQueue<K>
    extends java.lang.Object
    implements PriorityQueue<K>, java.io.Serializable
    A synchronized wrapper class for priority queues.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long serialVersionUID  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changed()
      Notifies the queue that the first element has changed (optional operation).
      void clear()
      Removes all elements from this queue.
      java.util.Comparator<? super K> comparator()
      Returns the comparator associated with this queue, or null if it uses its elements' natural ordering.
      K dequeue()
      Dequeues the first element from the queue.
      void enqueue​(K x)
      Enqueues a new element.
      boolean equals​(java.lang.Object o)  
      K first()
      Returns the first element of the queue.
      int hashCode()  
      boolean isEmpty()
      Checks whether this queue is empty.
      K last()
      Returns the last element of the queue, that is, the element the would be dequeued last (optional operation).
      int size()
      Returns the number of elements in this queue.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • enqueue

        public void enqueue​(K x)
        Description copied from interface: PriorityQueue
        Enqueues a new element.
        Specified by:
        enqueue in interface PriorityQueue<K>
        Parameters:
        x - the element to enqueue.
      • dequeue

        public K dequeue()
        Description copied from interface: PriorityQueue
        Dequeues the first element from the queue.
        Specified by:
        dequeue in interface PriorityQueue<K>
        Returns:
        the dequeued element.
      • first

        public K first()
        Description copied from interface: PriorityQueue
        Returns the first element of the queue.
        Specified by:
        first in interface PriorityQueue<K>
        Returns:
        the first element.
      • last

        public K last()
        Description copied from interface: PriorityQueue
        Returns the last element of the queue, that is, the element the would be dequeued last (optional operation).

        This default implementation just throws an UnsupportedOperationException.

        Specified by:
        last in interface PriorityQueue<K>
        Returns:
        the last element.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: PriorityQueue
        Checks whether this queue is empty.

        This default implementation checks whether PriorityQueue.size() is zero.

        Specified by:
        isEmpty in interface PriorityQueue<K>
        Returns:
        true if this queue is empty.
      • size

        public int size()
        Description copied from interface: PriorityQueue
        Returns the number of elements in this queue.
        Specified by:
        size in interface PriorityQueue<K>
        Returns:
        the number of elements in this queue.
      • clear

        public void clear()
        Description copied from interface: PriorityQueue
        Removes all elements from this queue.
        Specified by:
        clear in interface PriorityQueue<K>
      • changed

        public void changed()
        Description copied from interface: PriorityQueue
        Notifies the queue that the first element has changed (optional operation).

        This default implementation just throws an UnsupportedOperationException.

        Specified by:
        changed in interface PriorityQueue<K>
      • comparator

        public java.util.Comparator<? super K> comparator()
        Description copied from interface: PriorityQueue
        Returns the comparator associated with this queue, or null if it uses its elements' natural ordering.
        Specified by:
        comparator in interface PriorityQueue<K>
        Returns:
        the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object