|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--weiss.nonstandard.BinaryHeap
Implements a binary heap. Note that all "matching" is based on the compareTo method.
| Inner classes inherited from class weiss.nonstandard.PriorityQueue |
PriorityQueue.Position |
| Constructor Summary | |
BinaryHeap()
Construct the binary heap. |
|
BinaryHeap(java.lang.Comparable[] items)
Construct the binary heap from an array. |
|
| Method Summary | |
void |
decreaseKey(PriorityQueue.Position p,
java.lang.Comparable newVal)
Change the value of the item stored in the pairing heap. |
java.lang.Comparable |
deleteMin()
Remove the smallest item from the priority queue. |
java.lang.Comparable |
findMin()
Find the smallest item in the priority queue. |
PriorityQueue.Position |
insert(java.lang.Comparable x)
Insert into the priority queue. |
boolean |
isEmpty()
Test if the priority queue is logically empty. |
static void |
main(java.lang.String[] args)
|
void |
makeEmpty()
Make the priority queue logically empty. |
int |
size()
Returns size. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BinaryHeap()
public BinaryHeap(java.lang.Comparable[] items)
items - the inital items in the binary heap.| Method Detail |
public PriorityQueue.Position insert(java.lang.Comparable x)
insert in interface PriorityQueuex - the item to insert.
public void decreaseKey(PriorityQueue.Position p,
java.lang.Comparable newVal)
PriorityQueuedecreaseKey in interface PriorityQueuejava.lang.IllegalArgumentException - because no Positions are returned
by the insert method for BinaryHeap.public java.lang.Comparable findMin()
findMin in interface PriorityQueueUnderflowException - if empty.public java.lang.Comparable deleteMin()
deleteMin in interface PriorityQueueUnderflowException - if empty.public boolean isEmpty()
isEmpty in interface PriorityQueuepublic int size()
size in interface PriorityQueuepublic void makeEmpty()
makeEmpty in interface PriorityQueuepublic static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||