|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.util.Heap
Implementations of Heap functions in Java. This code is derived from the HeapSort example algorithm in Introduction to algorithms by Cormen, Leiserson and Rivest. Intentionally very simple.
Constructor Summary | |
Heap()
|
|
Heap(java.lang.Comparable[] keys,
java.lang.Object[] objects,
int numElem)
|
Method Summary | |
void |
add(java.lang.Object elem,
java.lang.Comparable key)
Adds an element to the heap with the given key. |
void |
clear()
|
java.lang.Object |
extractMin()
Removes the minimum element and its key from the heap, and returns the minimum element. |
Bag |
extractMin(Bag putInHere)
Removes all key-equal minimum elements and adds them to a Bag, which is then is returned. |
Bag |
extractMin(java.lang.Comparable comparable,
Bag putInHere)
Removes elements in order and adds them to a Bag, so long as the provided Comparable object is equal to their keys. |
java.lang.Comparable |
getMinKey()
Returns the key value of the current min element. |
boolean |
isEmpty()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Heap()
public Heap(java.lang.Comparable[] keys, java.lang.Object[] objects, int numElem)
Method Detail |
public java.lang.Comparable getMinKey()
public Bag extractMin(java.lang.Comparable comparable, Bag putInHere)
public Bag extractMin(Bag putInHere)
public java.lang.Object extractMin()
public void add(java.lang.Object elem, java.lang.Comparable key)
public boolean isEmpty()
public void clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |