a min queue using C++ STL priority_queue class


👍 g++ -std=c++11 
   stl_priority_queue_min.cpp 
👍 ./a.out
1 2 3

👍 cat stl_priority_queue_min.cpp 
#include <iostream>
#include <queue>
using namespace std;

int main() {
  priority_queue<int, 
                 vector<int>, 
                 greater<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