klips/cpp/datastructs/maxheap/driver.cpp

71 lines
1.7 KiB
C++
Raw Permalink Normal View History

2020-07-10 02:20:14 +00:00
/*#############################################################################
## Author: Shaun Reed ##
## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ##
## About: A driver program to test a max heap implementation ##
## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################
## driver.cpp
*/
#include "maxheap.h"
#include <iostream>
enum OPS {
EXIT, INSERT, DELETE, PRINT, EMPTY, MIN, MAX
};
int main()
{
std::cout << "Driver: \n";
MaxHeap testList;
bool exit = false;
int choice = -1;
int val;
2020-07-12 00:35:49 +00:00
while (!exit) {
2020-07-10 02:20:14 +00:00
std::cout << "##### Max Heap Menu #####\n\t0. Exit"
"\n\t1. Insert\n\t2. Delete\n\t3. Print"
<< "\n\t4. Empty\n\t5. Min\n\t6. Max\n";
std::cin >> choice;
std::cin.clear();
switch (choice) {
case EXIT:
exit = true;
break;
case INSERT:
std::cout << "Enter a value to insert to our tree: ";
std::cin >> val;
std::cin.clear();
testList.insert(val);
break;
case DELETE:
testList.del();
break;
case PRINT:
testList.print();
break;
case EMPTY:
testList.makeEmpty();
break;
case MIN:
2020-07-12 00:35:49 +00:00
std::cout << "Min value within our heap: " << testList.findMin() << std::endl;
2020-07-10 02:20:14 +00:00
break;
case MAX:
2020-07-12 00:35:49 +00:00
std::cout << "Max value within our heap: " << testList.findMax() << std::endl;
2020-07-10 02:20:14 +00:00
break;
default:
std::cout << "Invalid entry...\n";
break;
}
}
2020-07-12 00:35:49 +00:00
}