
#ifdef GNU
#include <iostream.h>
#define std
#else
#include <iostream>
#endif
#include <string>

float Min_Val( ) { return -1.0e08; }

#include "heap.h"

bool
NextFloat( float& value )
{
  std::string str;
  do {
    std::cout << "Enter a float to put into the heap\n"
              << "(type -1 to end) ==> ";
    if ( ! (std::cin >> value) ) {
      if ( std::cin.eof() ) 
	     return false;
      else {
	     std::cin.clear();
	     std::cout << "Error in input.  Press <Enter> until you see the prompt again...\n";
	     std::getline( std::cin, str );
      }
    }
    else {
      return value != -1;
    }
  } while (true);
} 


int
main()
{
  Binary_Heap<float> heap1(10);

  do {
    float in_value;
    if ( NextFloat(in_value) ) {
      heap1.Insert( in_value );
    }
    else {
      break;
    }
  } while ( ! heap1.Is_Full()  );

  if ( heap1.Is_Full() ) {
    std::cout << "The heap is now full.\n";
  }
  std::cout << "\nHere are the values stored in the heap in increasing order.\n";

  while ( ! heap1.Is_Empty() ) {
    float value = heap1.Delete_Min();
    std::cout << value << "\n";
  }
}
