sim.util
Class Heap

java.lang.Object
  extended bysim.util.Heap
All Implemented Interfaces:
java.io.Serializable

public class Heap
extends java.lang.Object
implements java.io.Serializable

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.

See Also:
Serialized Form

Constructor Summary
Heap()
           
Heap(double[] keys, java.lang.Object[] objects, int numElem)
           
 
Method Summary
 void add(java.lang.Object elem, double 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.
 double 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

Heap

public Heap()

Heap

public Heap(double[] keys,
            java.lang.Object[] objects,
            int numElem)
Method Detail

getMinKey

public double getMinKey()
Returns the key value of the current min element. Does not extract the element.


extractMin

public java.lang.Object extractMin()
Removes the minimum element and its key from the heap, and returns the minimum element. Will return null if the heap is empty


add

public void add(java.lang.Object elem,
                double key)
Adds an element to the heap with the given key.


isEmpty

public boolean isEmpty()

clear

public void clear()