E
- Type of elements in the priority queuepublic class BinaryHeapPriorityQueue<E> extends java.util.AbstractSet<E> implements PriorityQueue<E>, java.util.Iterator<E>
Constructor and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
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 maxKeysToPrint elements.
|
java.lang.String |
toVerticalString() |
addAll, containsAll, retainAll, toArray, toArray
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)
public boolean hasNext()
hasNext
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 assesspublic boolean add(E key)
public boolean add(E key, double priority)
add
in interface PriorityQueue<E>
public boolean remove(java.lang.Object key)
public boolean relaxPriority(E key, double priority)
relaxPriority
in interface PriorityQueue<E>
key
- an Object
valuepublic boolean decreasePriority(E key, double priority)
key
- an Object
valuepublic boolean changePriority(E key, double priority)
changePriority
in interface PriorityQueue<E>
key
- an Object
valuepublic boolean isEmpty()
public int size()
public boolean contains(java.lang.Object key)
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()
public void clear()
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)