Interface PriorityQueue<K>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void changed()
      Notifies the queue that the first element has changed (optional operation).
      void clear()
      Removes all elements from this queue.
      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.
      K first()
      Returns the first element of the queue.
      default boolean isEmpty()
      Checks whether this queue is empty.
      default 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.
    • Method Detail

      • enqueue

        void enqueue​(K x)
        Enqueues a new element.
        Parameters:
        x - the element to enqueue.
      • dequeue

        K dequeue()
        Dequeues the first element from the queue.
        Returns:
        the dequeued element.
        Throws:
        NoSuchElementException - if the queue is empty.
      • isEmpty

        default boolean isEmpty()
        Checks whether this queue is empty.

        This default implementation checks whether size() is zero.

        Returns:
        true if this queue is empty.
      • size

        int size()
        Returns the number of elements in this queue.
        Returns:
        the number of elements in this queue.
      • clear

        void clear()
        Removes all elements from this queue.
      • first

        K first()
        Returns the first element of the queue.
        Returns:
        the first element.
        Throws:
        NoSuchElementException - if the queue is empty.
      • last

        default K last()
        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.

        Returns:
        the last element.
        Throws:
        NoSuchElementException - if the queue is empty.
      • changed

        default void changed()
        Notifies the queue that the first element has changed (optional operation).

        This default implementation just throws an UnsupportedOperationException.

      • comparator

        Comparator<? super K> comparator()
        Returns the comparator associated with this queue, or null if it uses its elements' natural ordering.
        Returns:
        the comparator associated with this sorted set, or null if it uses its elements' natural ordering.