#include #include "pQueue.h" #include "Fields.h" #include using namespace std; main() { pQueue p; Fields f; string *s; int key; while (f.get_line() >= 0) { // we need to use a pointer to a string because a Jval cannot store // a string (it can store a char * but it cannot store a string) s = new string(f.get_current_line()); sscanf(f.get_field(0).c_str(), "%d", &key); p.insert(key, new_jval_v(s)); } printf("Heap Contents\n"); p.print(); Jval val; printf("\nStrings in sorted order\n"); while (!p.isEmpty()) { p.deleteMin(key, val); s = (string *) val.v; cout << *s; } }