Constructor and Description |
---|
Heap()
Constructor: an empty heap.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E e,
double p)
Add e with priority p to the priority queue.
|
boolean |
isEmpty()
Return true iff the priority queue is empty.
|
E |
peek()
Return the element of the priority queue with lowest priority, without
changing the queue.
|
E |
poll()
Remove and return the element of the priority queue with lowest priority.
|
int |
size()
Return the number of elements in the priority queue.
|
java.lang.String |
toString()
Return a string that gives this priority queue, in the format:
[item0:priority0, item1:priority1, ..., item(N-1):priority(N-1)]
Thus, the list is delimited by '[' and ']' and ", " (i.e.
|
java.lang.String |
toStringPriorities()
Return a string that gives the priorities in this priority queue,
in the format: [priority0, priority1, ..., priority(N-1)]
Thus, the list is delimited by '[' and ']' and ", " (i.e.
|
void |
updatePriority(E e,
double p)
Change the priority of element e to p.
|
public java.lang.String toString()
public java.lang.String toStringPriorities()
public int size()
public boolean isEmpty()
public void add(E e, double p) throws java.lang.IllegalArgumentException
public E peek()
public E poll()
public void updatePriority(E e, double p)
updatePriority
in interface PCue<E>