|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
public void enqueue(int index)
index
- the element to enqueue..public int dequeue()
NoSuchElementException
- if the queue is empty.public boolean isEmpty()
public int size()
public void clear()
public int first()
NoSuchElementException
- if the queue is empty.public int last()
NoSuchElementException
- if the queue is empty.public void changed()
public Comparator comparator()
null
if it uses its elements' natural ordering.
null
if it uses its elements' natural ordering.public void changed(int index)
Note that the specified element must belong to the queue.
index
- the element that has changed.
NoSuchElementException
- if the specified element is not in the queue.public void allChanged()
public void remove(int index)
Note that the specified element must belong to the queue.
index
- the element to be removed.
NoSuchElementException
- if the specified element is not in the queue.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |