#ifndef HEAP_H
#define HEAP_H 1
#include <iostream>
#include <stdlib.h>
#include "TreeNode.cpp"

class Heap
{
  public:
    Heap( int capacity = 200 );

    bool insert( int key,  TreeNode* x );
    TreeNode* removeMin();
    bool isEmpty( ) const;
    bool isFull( ) const;
    int  findMin(TreeNode*& minItem ) const;
    // works the same as removeMin but returns the node through
    // refernce argument.
    int  deleteMin( TreeNode*& minItem );

    void makeEmpty( );

  private:
    int   currentSize;  // Number of elements in heap
    int   capacity;     // the overall size of the heap
    int*   key;         // array of keys. Heap is based on the keys
    TreeNode** array;        // The data array. Each key has an associated data

    void buildHeap( );
    void percolateDown( int hole );
};
#endif

