T
- the type of the items stored in the queue.P
- the type of the priority of each item.public interface UpdatablePriorityQueue<T,P extends java.lang.Comparable<? super P>> extends PriorityQueue<PriorityPair<T,P>>
The items in an updatable priority queue must be unique; otherwise the operations of getting or setting an item's priority would not be well-defined (which copy of the item would we mean?).
Each implementation of this interface shall define a special "sentinel" priority value that indicates an item is not in the queue. Setting an item's priority to this value in fact removes it from the queue. Removing a non-member item is a no-op.
In addition, adding an item may be accomplished, from the user side, simply by setting its priority to a non-sentinel value.
Modifier and Type | Method and Description |
---|---|
void |
add(PriorityPair<T,P> itemPair)
Adds an item, with the priority given in the pair, to the queue.
|
void |
add(T item,
P priority)
Adds an item, with the given priority, to the queue.
|
P |
getPriority(T item)
Returns the priority of the given item, or, if that item is not in the
queue, an implementation-specific sentinel value.
|
P |
nonMemberPriority()
Returns the sentinel value used by getPriority() to indicate items not
currently stored in the queue.
|
boolean |
setPriority(T item,
P newPriority)
Sets the priority of a given item.
|
clear, isEmpty, peek, remove
void add(PriorityPair<T,P> itemPair)
add
in interface PriorityQueue<PriorityPair<T,P extends java.lang.Comparable<? super P>>>
void add(T item, P priority)
boolean setPriority(T item, P newPriority)
The consequences of this operation vary depending on two conditions:
The four cases covered by combinations of these conditions are:
The method returns true if the pair (item, newPriority) is in the queue after the call. (This is !DEL: true in cases 1 and 2; false in 3 and 4.)
P getPriority(T item)
P nonMemberPriority()