|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<E>
edu.stanford.nlp.util.FixedPrioritiesPriorityQueue<E>
public class FixedPrioritiesPriorityQueue<E>
A priority queue based on a binary heap. This implementation trades
flexibility for speed: while it is up to 2x faster than BinaryHeapPriorityQueue and nearly as fast as PriorityQueue, it does not support removing or changing the
priority of an element. Also, while getPriority(Object key) is supported, performance will be linear, not
constant.
| Constructor Summary | |
|---|---|
FixedPrioritiesPriorityQueue()
|
|
FixedPrioritiesPriorityQueue(int capacity)
|
|
| Method Summary | |
|---|---|
boolean |
add(E key,
double priority)
Adds a key to the queue with the given priority. |
boolean |
changePriority(E key,
double priority)
Not supported in this implementation. |
void |
clear()
|
FixedPrioritiesPriorityQueue<E> |
clone()
Returns a clone of this priority queue. |
E |
getFirst()
Returns the highest-priority element without removing it from the queue. |
double |
getPriority()
Gets the priority of the highest-priority element of the queue. |
double |
getPriority(java.lang.Object key)
Note that this method will be linear (not constant) time in this implementation! Better not to use it. |
boolean |
hasNext()
Returns true if the priority queue is non-empty |
java.util.Iterator<E> |
iterator()
|
static void |
main(java.lang.String[] args)
|
E |
next()
Returns the element in the queue with highest priority, and pops it from the queue. |
boolean |
relaxPriority(E key,
double priority)
Not supported in this implementation. |
void |
remove()
Not supported -- next() already removes the head of the queue. |
E |
removeFirst()
Returns the highest-priority element and removes it from the queue. |
int |
size()
Number of elements in the queue. |
java.util.List<E> |
toSortedList()
|
java.lang.String |
toString()
Returns a representation of the queue in decreasing priority order. |
java.lang.String |
toString(int maxKeysToPrint)
Returns a representation of the queue in decreasing priority order, displaying at most maxKeysToPring elements. |
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
add, addAll, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
add, addAll, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public FixedPrioritiesPriorityQueue()
public FixedPrioritiesPriorityQueue(int capacity)
| Method Detail |
|---|
public boolean hasNext()
hasNext in interface java.util.Iterator<E>public E next()
next in interface java.util.Iterator<E>public void remove()
remove in interface java.util.Iterator<E>
public boolean add(E key,
double priority)
add in interface PriorityQueue<E>
public boolean changePriority(E key,
double priority)
changePriority in interface PriorityQueue<E>key - an E value
public E getFirst()
getFirst in interface PriorityQueue<E>public double getPriority(java.lang.Object key)
getPriority in interface PriorityQueue<E>key - The object to assess
public double getPriority()
getPriority in interface PriorityQueue<E>
public boolean relaxPriority(E key,
double priority)
relaxPriority in interface PriorityQueue<E>public E removeFirst()
removeFirst in interface PriorityQueue<E>public java.util.List<E> toSortedList()
toSortedList in interface PriorityQueue<E>public int size()
size in interface java.util.Collection<E>size in interface java.util.Set<E>size in class java.util.AbstractCollection<E>public void clear()
clear in interface java.util.Collection<E>clear in interface java.util.Set<E>clear in class java.util.AbstractCollection<E>public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>iterator in interface java.util.Collection<E>iterator in interface java.util.Set<E>iterator in class java.util.AbstractCollection<E>public java.lang.String toString()
toString in class java.util.AbstractCollection<E>public java.lang.String toString(int maxKeysToPrint)
toString in interface PriorityQueue<E>maxKeysToPrint - The maximum number of keys to print. Less are
printed if there are less than this number of items in the
PriorityQueue. If this number is non-positive, then all elements in
the PriorityQueue are printed.
public FixedPrioritiesPriorityQueue<E> clone()
clone in class java.lang.Objectpublic static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||