|
|||||||||
| 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.BinaryHeapPriorityQueue<E>
E - Type of elements in the priority queuepublic class BinaryHeapPriorityQueue<E>
PriorityQueue with explicit double priority values. Larger doubles are higher priorities. BinaryHeap-backed. For each entry, uses ~ 24 (entry) + 16? (Map.Entry) + 4 (List entry) = 44 bytes?
| Constructor Summary | |
|---|---|
BinaryHeapPriorityQueue()
|
|
BinaryHeapPriorityQueue(int initCapacity)
|
|
BinaryHeapPriorityQueue(MapFactory<E,edu.stanford.nlp.util.BinaryHeapPriorityQueue.Entry<E>> mapFactory)
|
|
BinaryHeapPriorityQueue(MapFactory<E,edu.stanford.nlp.util.BinaryHeapPriorityQueue.Entry<E>> mapFactory,
int initCapacity)
|
|
| Method Summary | |
|---|---|
boolean |
add(E key)
Adds an object to the queue with the minimum priority (Double.NEGATIVE_INFINITY). |
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. |
void |
clear()
Clears the queue. |
boolean |
contains(java.lang.Object key)
Returns whether the queue contains the given key. |
boolean |
decreasePriority(E key,
double priority)
Demotes a key in the queue, adding it if it wasn't there already. |
BinaryHeapPriorityQueue<E> |
deepCopy()
|
BinaryHeapPriorityQueue<E> |
deepCopy(MapFactory<E,edu.stanford.nlp.util.BinaryHeapPriorityQueue.Entry<E>> mapFactory)
|
E |
getFirst()
Finds the object with the highest priority and returns it, without modifying the queue. |
E |
getObject(E key)
Searches for the object in the queue and returns it. |
double |
getPriority()
Gets the priority of the highest-priority element of the queue. |
double |
getPriority(E key)
Get the priority of a key -- if the key is not in the queue, Double.NEGATIVE_INFINITY is returned. |
boolean |
hasNext()
|
boolean |
isEmpty()
Checks if the queue is empty. |
java.util.Iterator<E> |
iterator()
|
static void |
main(java.lang.String[] args)
|
E |
next()
|
boolean |
relaxPriority(E key,
double priority)
Promotes a key in the queue, adding it if it wasn't there already. |
void |
remove()
|
boolean |
remove(java.lang.Object key)
|
E |
removeFirst()
Finds the object with the highest priority, removes it, and returns it. |
int |
size()
Get the number of elements in the queue. |
java.util.List<E> |
toSortedList()
|
java.lang.String |
toString()
|
java.lang.String |
toString(int maxKeysToPrint)
Returns a representation of the queue in decreasing priority order, displaying at most maxKeysToPring elements. |
java.lang.String |
toVerticalString()
|
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, containsAll, retainAll, toArray, toArray |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public BinaryHeapPriorityQueue()
public BinaryHeapPriorityQueue(int initCapacity)
public BinaryHeapPriorityQueue(MapFactory<E,edu.stanford.nlp.util.BinaryHeapPriorityQueue.Entry<E>> mapFactory)
public BinaryHeapPriorityQueue(MapFactory<E,edu.stanford.nlp.util.BinaryHeapPriorityQueue.Entry<E>> mapFactory,
int initCapacity)
| 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 E removeFirst()
removeFirst in interface PriorityQueue<E>public E getFirst()
getFirst in interface PriorityQueue<E>public double getPriority()
getPriority in interface PriorityQueue<E>public E getObject(E key)
public double getPriority(E key)
getPriority in interface PriorityQueue<E>key - The object to assess
public boolean add(E key)
add in interface java.util.Collection<E>add in interface java.util.Set<E>add in class java.util.AbstractCollection<E>key - an Object value
public boolean add(E key,
double priority)
add in interface PriorityQueue<E>public boolean remove(java.lang.Object key)
remove in interface java.util.Collection<E>remove in interface java.util.Set<E>remove in class java.util.AbstractCollection<E>
public boolean relaxPriority(E key,
double priority)
relaxPriority in interface PriorityQueue<E>key - an Object value
public boolean decreasePriority(E key,
double priority)
key - an Object value
public boolean changePriority(E key,
double priority)
changePriority in interface PriorityQueue<E>key - an Object value
public boolean isEmpty()
isEmpty in interface java.util.Collection<E>isEmpty in interface java.util.Set<E>isEmpty in class java.util.AbstractCollection<E>boolean valuepublic int size()
size in interface java.util.Collection<E>size in interface java.util.Set<E>size in class java.util.AbstractCollection<E>public boolean contains(java.lang.Object key)
contains in interface java.util.Collection<E>contains in interface java.util.Set<E>contains in class java.util.AbstractCollection<E>public java.util.List<E> toSortedList()
toSortedList in interface PriorityQueue<E>public BinaryHeapPriorityQueue<E> deepCopy(MapFactory<E,edu.stanford.nlp.util.BinaryHeapPriorityQueue.Entry<E>> mapFactory)
public BinaryHeapPriorityQueue<E> deepCopy()
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 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.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 java.lang.String toVerticalString()
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||