本文整理汇总了C++中PriorityQueue::printPQ方法的典型用法代码示例。如果您正苦于以下问题:C++ PriorityQueue::printPQ方法的具体用法?C++ PriorityQueue::printPQ怎么用?C++ PriorityQueue::printPQ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue::printPQ方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
PriorityQueue<string> pq;
PQVector<string> pqv;
string elem;
int what = 1;
cout << "1. Priority Queue with Binary Heap\n2. Priority Queue with Vector\nChoic: ";
cin >> what;
if(what ==1){
string again, right, left;
left = 'y'; right = 'Y'; again = 'Y';
elem = "abc"; pq.insertItem(3, elem);
elem = "2ab"; pq.insertItem(4, elem);
elem = "bbc"; pq.insertItem(1, elem);
elem = "cnn"; pq.insertItem(5, elem);
elem = "ddn"; pq.insertItem(6, elem);
elem = "eda"; pq.insertItem(7, elem);
elem = "ggg"; pq.insertItem(9, elem);
elem = "kkk"; pq.insertItem(10, elem);
elem = "lll"; pq.insertItem(11, elem);
elem = "mmm"; pq.insertItem(12, elem);
// elem = "qqq"; pq.insertItem(16, elem);
cout << "\nAlready inserted heaps\n";
cout << "===============\n";
pq.printPQ();
cout << "===============\n";
// cout << "---------Before Removing Min\n";
// cout << "minElement: " << pq.minElement() << endl;
// cout << "minKey: " << pq.minKey() << endl;
// cout << "Min element removed." << endl;
// pq.remove(pq.min());
// cout << "--------After removing min\n";
// cout << "minElement: " << pq.minElement() << endl;
// cout << "minKey: " << pq.minKey() << endl;
// pq.decreaseKey(pq.min(),pq.minKey());
// cout << "--------After decreasing loc 3\n";
// pq.decreaseKey(3,6);
// cout << "================\n";
// pq.decreaseKey(pq.minKey(), pq.min());
while (again.compare(right) == 0 || again.compare(left) == 0)
{
char choi;
cout << "What would you like to do? (Press corresponding number and hit enter)"<<endl;
cout << "1. Insert items into a priority queue."<<endl;
cout << "2. Print out priority queue."<<endl;
cout << "3. Remove an item with a specific location."<<endl;
cout << "4. Find item with minimum key."<<endl;
cout << "5. Decrease Key."<<endl;
cout << "6. Build Priority Queue." << endl;
cout << "7. Exit."<<endl;
cout << "Choie: ";
cin >> choi;
if(choi == '1')
{
int key;
char element[255];
cout << "Key: ";
cin >> key;
cout << "Elem: ";
cin >> element;
pq.insertItem(key, element);
}
else if(choi == '2')