public class Heap
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Heap() |
Heap(java.lang.Comparable[] keys,
java.lang.Object[] objects) |
Modifier and Type | Method and Description |
---|---|
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 first 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.
|
java.lang.Comparable[] |
getKeys() |
java.lang.Object |
getMin()
Returns the current min element.
|
java.lang.Comparable |
getMinKey()
Returns the key value of the current min element.
|
java.lang.Object[] |
getObjects() |
boolean |
isEmpty() |
Heap |
merge(Heap other)
Produces a new heap which is the union of this heap with the other.
|
int |
size() |
public Heap()
public Heap(java.lang.Comparable[] keys, java.lang.Object[] objects)
public java.lang.Comparable[] getKeys()
public java.lang.Object[] getObjects()
public java.lang.Comparable getMinKey()
public java.lang.Object getMin()
public Bag extractMin(Bag putInHere)
public java.lang.Object extractMin()
public void add(java.lang.Object elem, java.lang.Comparable key)
public int size()
public boolean isEmpty()
public void clear()