Class IndirectPriorityQueues.SynchronizedIndirectPriorityQueue<K>

java.lang.Object
it.unimi.dsi.fastutil.IndirectPriorityQueues.SynchronizedIndirectPriorityQueue<K>
All Implemented Interfaces:
IndirectPriorityQueue<K>
Enclosing class:
IndirectPriorityQueues

public static class IndirectPriorityQueues.SynchronizedIndirectPriorityQueue<K>
extends java.lang.Object
implements IndirectPriorityQueue<K>
A synchronized wrapper class for indirect priority queues.
  • Field Summary

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

    Modifier and Type Method Description
    void allChanged()
    Notifies this queue that the all elements have changed (optional operation).
    void changed()
    Notifies this queue that the first element has changed (optional operation).
    void changed​(int i)
    Notifies this queue that the specified 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.
    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 x)
    Enqueues a new element.
    int first()
    Returns the first element of this queue.
    int front​(int[] a)
    Retrieves the front of this queue in a given array (optional operation).
    boolean isEmpty()
    Checks whether this queue is empty.
    int last()
    Returns the last element of this queue, that is, the element the would be dequeued last (optional operation).
    boolean remove​(int i)
    Removes the specified element from this queue (optional operation).
    int size()
    Returns the number of elements in this queue.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • enqueue

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

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

      public boolean contains​(int index)
      Description copied from interface: IndirectPriorityQueue
      Checks whether a given index belongs to this queue (optional operation).

      This default implementation just throws an UnsupportedOperationException.

      Specified by:
      contains in interface IndirectPriorityQueue<K>
      Parameters:
      index - an index possibly in the queue.
      Returns:
      true if the specified index belongs to this queue.
    • first

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

      public int last()
      Description copied from interface: IndirectPriorityQueue
      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.

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

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

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

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

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

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

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

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

      Specified by:
      changed in interface IndirectPriorityQueue<K>
    • allChanged

      public void allChanged()
      Description copied from interface: IndirectPriorityQueue
      Notifies this queue that the all elements have changed (optional operation).

      This default implementation just throws an UnsupportedOperationException.

      Specified by:
      allChanged in interface IndirectPriorityQueue<K>
    • changed

      public void changed​(int i)
      Description copied from interface: IndirectPriorityQueue
      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.

      Specified by:
      changed in interface IndirectPriorityQueue<K>
      Parameters:
      i - the element that has changed.
    • remove

      public boolean remove​(int i)
      Description copied from interface: IndirectPriorityQueue
      Removes the specified element from this queue (optional operation).

      This default implementation just throws an UnsupportedOperationException.

      Specified by:
      remove in interface IndirectPriorityQueue<K>
      Parameters:
      i - the element to be removed.
      Returns:
      true if the index was in the queue.
    • comparator

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

      public int front​(int[] a)
      Description copied from interface: IndirectPriorityQueue
      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.

      Specified by:
      front in interface IndirectPriorityQueue<K>
      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).