|
|||||||||
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(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 |
Iterator<E> |
iterator()
|
static void |
main(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. |
List<E> |
toSortedList()
|
String |
toString()
Returns a representation of the queue in decreasing priority order. |
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 Iterator<E>
public E next()
next
in interface Iterator<E>
public void remove()
remove
in interface Iterator<E>
public boolean add(E key, double priority)
add
in interface PriorityQueue<E>
key
- priority
-
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(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 List<E> toSortedList()
toSortedList
in interface PriorityQueue<E>
public int size()
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractCollection<E>
public void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in interface Set<E>
iterator
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
public String toString(int maxKeysToPrint)
maxKeysToPrint
- public FixedPrioritiesPriorityQueue<E> clone()
clone
in class Object
public static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |