com.meapsoft
Class MaxHeap

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

public class MaxHeap
extends Heap

Implementation of a binary max 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
MaxHeap()
          Creates an empty MaxHeap.
MaxHeap(java.util.Collection c)
          Create a new MaxHeap containing the elements of the given Collection.
MaxHeap(java.util.Comparator c)
          Use given Comparator for all comparisons between elements in this MaxHeap.
MaxHeap(int capacity)
          Creates an empty MaxHeap with the given capacity.
 
Method Summary
protected  int cmp(int node1, int node2)
          Compare two Objects in this heap - wrapper around compareTo/Comparator.compare
 java.lang.Object deleteMax()
          Delete the largest element of this MaxHeap.
static void main(java.lang.String[] args)
           
 
Methods inherited from class com.meapsoft.Heap
add, addAll, isHeap, rebuildHeap, remove, remove, sort
 
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

MaxHeap

public MaxHeap()
Creates an empty MaxHeap.


MaxHeap

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


MaxHeap

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


MaxHeap

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

Method Detail

deleteMax

public java.lang.Object deleteMax()
Delete the largest element of this MaxHeap.


cmp

protected int cmp(int node1,
                  int node2)
Compare two Objects in this heap - wrapper around compareTo/Comparator.compare

Overrides:
cmp in class Heap

main

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