maximum priority queue c++ code example

Example 1: min heap priority queue c++

#include<queue>
std::priority_queue <int, std::vector<int>, std::greater<int> > minHeap;

Example 2: priority queue in c++

//Shubh'grepper
// Implementation of priority_queue in c++

//queue with elements in decreasing order
priority_queue<int> pq;

// queue with elements in increasing order  using compare function inside declaration
priority_queue <int, vector<int>, greater<int> > pq;

//priority_queue of type pair<int, int>
#define pp pair<int, int>
priority_queue <pp, vector<pp>, greater<pp> > pq;

Tags:

Java Example