|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface PriorityQueue<E>
A Set that also represents an ordering of its elements, and responds
quickly to add(), changePriority(),
removeFirst(), and getFirst() method calls.
PriorityQueue:
double values
as priorities for queue elements, while
java.util.PriorityQueue uses either the elements'
natural order (see Comparable) or a Comparator.
doubles represent higher
priorities; in java.util.PriorityQueue, lesser
elements (with respect to the specified ordering) have higher
priorities.
java.util.PriorityQueue, that's not possible.
BinaryHeapPriorityQueue, is roughly 2x slower
than java.util.PriorityQueue in informal benchmark testing.
BinaryHeapPriorityQueue and nearly as
fast as PriorityQueue, it does not support removing or
changing the priority of an element.
On the other hand, this interface and PriorityQueue
also have some characteristics in common:
| Method Summary | |
|---|---|
boolean |
add(E key,
double priority)
Convenience method for if you want to pretend relaxPriority doesn't exist, or if you really want add's return conditions. |
boolean |
changePriority(E key,
double priority)
Changes a priority, either up or down, adding the key it if it wasn't there already. |
E |
getFirst()
Finds the object with the highest priority and returns it, without modifying the queue. |
double |
getPriority(Object key)
Get the priority of a key. |
boolean |
relaxPriority(E key,
double priority)
Increases the priority of the Object key to the new priority if the old priority was lower than the new priority. |
E |
removeFirst()
Finds the object with the highest priority, removes it, and returns it. |
List<E> |
toSortedList()
|
| Methods inherited from interface java.util.Set |
|---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Method Detail |
|---|
E removeFirst()
E getFirst()
double getPriority(Object key)
key - The object to assess
boolean add(E key, double priority)
boolean changePriority(E key, double priority)
key - an Object value
boolean relaxPriority(E key, double priority)
key - priority -
List<E> toSortedList()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||