Interface IndirectPriorityQueue<K>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void allChanged()
      Notifies this queue that the all elements have changed (optional operation).
      default void changed()
      Notifies this queue that the first element has changed (optional operation).
      default void changed​(int index)
      Notifies this queue that the specified 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.
      default boolean contains​(int index)
      Checks whether a given index belongs to this queue (optional operation).
      int dequeue()
      Dequeues the first element from this queue.
      void enqueue​(int index)
      Enqueues a new element.
      int first()
      Returns the first element of this queue.
      default int front​(int[] a)
      Retrieves the front of this queue in a given array (optional operation).
      default boolean isEmpty()
      Checks whether this queue is empty.
      default int last()
      Returns the last element of this queue, that is, the element the would be dequeued last (optional operation).
      default boolean remove​(int index)
      Removes the specified element from this queue (optional operation).
      int size()
      Returns the number of elements in this queue.
    • Method Detail

      • enqueue

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

        int dequeue()
        Dequeues the first element from this queue.
        Returns:
        the dequeued element.
        Throws:
        NoSuchElementException - if this 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

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

        default int last()
        Returns the last element of this 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 this queue is empty.
      • changed

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

        This default implementation just calls changed(int) with argument first().

      • 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.
      • changed

        default void changed​(int index)
        Notifies this queue that the specified element has changed (optional operation).

        Note that the specified element must belong to this queue.

        This default implementation just throws an UnsupportedOperationException.

        Parameters:
        index - the element that has changed.
        Throws:
        NoSuchElementException - if the specified element is not in this queue.
      • allChanged

        default void allChanged()
        Notifies this queue that the all elements have changed (optional operation).

        This default implementation just throws an UnsupportedOperationException.

      • contains

        default boolean contains​(int index)
        Checks whether a given index belongs to this queue (optional operation).

        This default implementation just throws an UnsupportedOperationException.

        Parameters:
        index - an index possibly in the queue.
        Returns:
        true if the specified index belongs to this queue.
      • remove

        default boolean remove​(int index)
        Removes the specified element from this queue (optional operation).

        This default implementation just throws an UnsupportedOperationException.

        Parameters:
        index - the element to be removed.
        Returns:
        true if the index was in the queue.
      • front

        default int front​(int[] a)
        Retrieves the front of this queue in a given array (optional operation).

        The front of an indirect queue is the set of indices whose associated elements in the reference array are equal to the element associated to the first index. These indices can be always obtain by dequeueing, but this method should retrieve efficiently such indices in the given array without modifying the state of this queue.

        This default implementation just throws an UnsupportedOperationException.

        Parameters:
        a - an array large enough to hold the front (e.g., at least long as the reference array).
        Returns:
        the number of elements actually written (starting from the first position of a).