it.unimi.dsi.fastutil
Interface IndirectPriorityQueue

All Known Subinterfaces:
IndirectDoublePriorityQueue
All Known Implementing Classes:
AbstractIndirectDoublePriorityQueue, AbstractIndirectPriorityQueue, ByteArrayIndirectDoublePriorityQueue, ByteHeapIndirectDoublePriorityQueue, ByteHeapSesquiIndirectDoublePriorityQueue, CharArrayIndirectDoublePriorityQueue, CharHeapIndirectDoublePriorityQueue, CharHeapSesquiIndirectDoublePriorityQueue, DoubleArrayIndirectDoublePriorityQueue, DoubleHeapIndirectDoublePriorityQueue, DoubleHeapSesquiIndirectDoublePriorityQueue, FloatArrayIndirectDoublePriorityQueue, FloatHeapIndirectDoublePriorityQueue, FloatHeapSesquiIndirectDoublePriorityQueue, IndirectDoublePriorityQueues.SynchronizedIndirectDoublePriorityQueue, IndirectPriorityQueues.SynchronizedIndirectPriorityQueue, IntArrayIndirectDoublePriorityQueue, IntHeapIndirectDoublePriorityQueue, IntHeapSesquiIndirectDoublePriorityQueue, LongArrayIndirectDoublePriorityQueue, LongHeapIndirectDoublePriorityQueue, LongHeapSesquiIndirectDoublePriorityQueue, ObjectArrayIndirectDoublePriorityQueue, ObjectHeapIndirectDoublePriorityQueue, ObjectHeapSesquiIndirectDoublePriorityQueue, ShortArrayIndirectDoublePriorityQueue, ShortHeapIndirectDoublePriorityQueue, ShortHeapSesquiIndirectDoublePriorityQueue

public interface IndirectPriorityQueue

An indirect priority queue.

An indirect priority queue provides a way to enqueue by index elements taken from a given reference list, and to dequeue them in some specified order. Elements that are smaller in the specified order are dequeued first. It is also possible to get the index of the first element, that is, the index that would be dequeued next.

Additionally, the queue may provide a method to peek at the index of the element that would be dequeued last.

The reference list should not change during queue operations (or, more precisely, the relative order of the elements in the queue should not change). Nonetheless, some implementations may give the caller a way to notify the queue that the first element has changed its relative position in the order.

Optionally, an indirect priority queue may even provide methods to notify the change of any element of the reference list, and to remove from the queue any element of the reference list presently in the queue. It may even allow to notify that all elements have changed.

It is always possible to enqueue two distinct indices corresponding to equal elements of the reference list. However, depending on the implementation, it may or may not be possible to enqueue twice the same index.

Note that all element manipulation happens via indices.


Method Summary
 void allChanged()
          Notifies the queue that the all elements have changed (optional operation).
 void changed()
          Notifies the queue that the first element has changed (optional operation).
 void changed(int index)
          Notifies the queue that the specified element has changed (optional operation).
 void clear()
          Removes all elements from this queue.
 Comparator comparator()
          Returns the comparator associated with this queue, or null if it uses its elements' natural ordering.
 int dequeue()
          Dequeues the first element from the queue.
 void enqueue(int index)
          Enqueues a new element.
 int first()
          Returns the first element of the queue.
 boolean isEmpty()
          Checks whether the queue is empty.
 int last()
          Returns the last element of the queue, that is, the element the would be dequeued last (optional operation).
 void remove(int index)
          Removes the specified element from the queue (optional operation).
 int size()
          Returns the number of elements in this queue.
 

Method Detail

enqueue

public void enqueue(int index)
Enqueues a new element.

Parameters:
index - the element to enqueue..

dequeue

public int dequeue()
Dequeues the first element from the queue.

Returns:
the dequeued element.
Throws:
NoSuchElementException - if the queue is empty.

isEmpty

public boolean isEmpty()
Checks whether the queue is empty.

Returns:
true if the queue is empty.

size

public int size()
Returns the number of elements in this queue.

Returns:
the number of elements in this queue.

clear

public void clear()
Removes all elements from this queue.


first

public int first()
Returns the first element of the queue.

Returns:
the first element.
Throws:
NoSuchElementException - if the queue is empty.

last

public int last()
Returns the last element of the queue, that is, the element the would be dequeued last (optional operation).

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

changed

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


comparator

public Comparator 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

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

Note that the specified element must belong to the queue.

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

allChanged

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


remove

public void remove(int index)
Removes the specified element from the queue (optional operation).

Note that the specified element must belong to the queue.

Parameters:
index - the element to be removed.
Throws:
NoSuchElementException - if the specified element is not in the queue.