public class Heap<V>
extends java.lang.Object
Constructor and Description |
---|
Heap()
Constructor: an empty heap with capacity 10.
|
Modifier and Type | Method and Description |
---|---|
void |
add(V v,
double p)
Add v with priority p to the heap.
|
void |
changePriority(V v,
double p)
Change the priority of value v to p.
|
void |
ensureSpace()
If size = length of c, double the length of array c.
|
V |
peek()
Return the value of this heap with lowest priority.
|
V |
poll()
Remove and return the element of this heap with lowest priority.
|
int |
size()
Return the number of values in this heap.
|
public void add(V v, double p) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void ensureSpace()
public int size()
public V peek()
public V poll()
public void changePriority(V v, double p)