//  File minheap.h

#ifndef _MINHEAP_H_
#define _MINHEAP_H_


class MinHeap
{
protected:
    int *heap;     //  A dynamically allocated array of values
    int size;      //  Number of values currently on the heap
    int capacity;  //  The maximum capacity of the heap

public:
    //  Creates a heap of the given size.  
    MinHeap(unsigned size);

    //  Deallocates the space held by the heap
    virtual ~MinHeap();

    //  Returns true if the heap is full; otherwise, returns false.
    bool is_full() const;

    //  Returns true if the heap is empty; otherwise, returns false.
    bool is_empty() const;

    //  Places the value n on the heap.  
    //  Clients should call is_full before calling enqueue to
    //  ensure that space on the heap is available.  
    //  The behavior of enqueue is undefined if the heap is full.
    void enqueue(int n);

    //  Returns the minimum value on the heap
    //  Clients should call is_empty before calling dequeue to
    //  ensure that an item is available on the heap.  
    //  The behavior of dequeue is undefined if the heap is full.
    int dequeue();

    //  Displays the contents of the heap for debugging
    //  purposes.
    void print() const;

    //  Draws a text-based graphical representation of the heap.
    void draw(int root, int depth, char link) const;
};


#endif
