T
- the type of data the queue stores.public interface PriorityQueue<T extends java.lang.Comparable<? super T>>
Note that the relative priority of elements is defined by the compareTo() method defined for the type of items stored in the queue. In other words, the priority of an item is equal to the value of the item.
Note that this interface defines a *max* priority queue; the item with the highest priority is what comes out of the queue. The easiest way to get a *min* priority queue is to separate priorities and values (in a PriorityPair), and negate the priorities that you use.
PriorityPair
,
DefaultPriorityPairImplementation
Modifier and Type | Method and Description |
---|---|
void |
add(T item)
Adds an item to the queue.
|
void |
clear()
Removes all items from the queue.
|
boolean |
isEmpty()
Returns true if the queue is empty.
|
T |
peek()
Returns the maximum item in the queue, without removing it.
|
T |
remove()
Removes the maximum item from the queue, and returns it.
|
void add(T item)
java.lang.IllegalArgumentException
- if item is null.T remove()
T peek()
boolean isEmpty()
void clear()