com.meapsoft
Class MinHeap

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.Vector
              extended bycom.meapsoft.Heap
                  extended bycom.meapsoft.MinHeap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class MinHeap
extends Heap

Implementation of a binary min heap

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.meapsoft.Heap
isHeap
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
MinHeap()
          Creates an empty MinHeap.
MinHeap(java.util.Collection c)
          Create a new MinHeap containing the elements of the given Collection.
MinHeap(java.util.Comparator c)
          Use given Comparator for all comparisons between elements in this MinHeap.
MinHeap(int capacity)
          Creates an empty MinHeap with the given capacity.
 
Method Summary
 java.lang.Object deleteMin()
          Delete the smallest element of this MinHeap.
static void main(java.lang.String[] args)
           
 void sort()
          Perform heap sort on the data stored in this heap.
 
Methods inherited from class com.meapsoft.Heap
add, addAll, cmp, isHeap, rebuildHeap, remove, remove
 
Methods inherited from class java.util.Vector
add, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

MinHeap

public MinHeap()
Creates an empty MinHeap.


MinHeap

public MinHeap(java.util.Comparator c)
Use given Comparator for all comparisons between elements in this MinHeap. Otherwise rely on compareTo methods and Comparable Objects.


MinHeap

public MinHeap(int capacity)
Creates an empty MinHeap with the given capacity.


MinHeap

public MinHeap(java.util.Collection c)
Create a new MinHeap containing the elements of the given Collection.

Method Detail

deleteMin

public java.lang.Object deleteMin()
Delete the smallest element of this MinHeap.


sort

public void sort()
Perform heap sort on the data stored in this heap. After calling sort, a call to this objects iterator() method will iterate through the data stored in the heap in sorted order. This is not a stable sort.

Overrides:
sort in class Heap

main

public static void main(java.lang.String[] args)