a simple example of C++ STL priority_queue class


👍 g++ stl_priority_queue.cpp
👍 ./a.out
3 2 1 
👍 cat stl_priority_queue.cpp 
#include <iostream>
#include <queue>
using namespace std;

int main() {
  priority_queue<int> pq1;
  pq1.push(3);
  pq1.push(1);
  pq1.push(2);
  while (!pq1.empty()) {
    cout << pq1.top() << ' ';
    pq1.pop();
  }
  cout << endl;
}

    

ch 4.6 PRIORITY QUEUES IN THE STANDARD TEMPLATE LIBRARY p152 of