T
- - type of elements in the implementing class.public interface MinHeap<T>
Modifier and Type | Method and Description |
---|---|
void |
add(T t,
double priority)
Add t with priority p to the Heap.
|
boolean |
isEmpty()
Return true iff the Heap is empty.
|
T |
poll()
Remove and return the minimum-valued element from the Heap,
in worst-case time no more than O(log N).
|
int |
size()
Return the size of the Heap.
|
java.lang.String |
toString()
Return a string that represents this heap, in the format:
[item1:priority1, item2:priority2, ..., itemN:priorityN]
Use the toString() function of the items.
|
void |
updatePriority(T t,
double p)
Change the priority of t to p.
|
java.lang.String toString()
toString
in class java.lang.Object
T poll()
void updatePriority(T t, double p)
void add(T t, double priority) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
int size()
boolean isEmpty()