Horje
priority queue in c++ Code Example
priority queue c++
priority_queue<int> pq;//this works like rank (e.g: rank=1 > rank=2)
//the lower the rank the higher is the priority
pq.push(3);
cout<<pq.top()<<endl;
cout<<pq.size()<<endl;
pq.pop();
if(pq.empty()){
  cout<<"priority queue is empty"<<endl;
}

priority_queue<int, vector<int>, greater<int>> pqr;
//this is the reverse priority queue
//this works like score the higher the score the more is it's priority
pqr.push(1);
pqr.push(4);
cout<<pqr.top()<<endl;
pqr.pop();
cout<<pqr.size()<<endl;
if(!pqr.empty()){
  cout<<"the priority queue is not empty"<<endl;
}
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;




Cpp

Related
print hello world in c++ Code Example print hello world in c++ Code Example
c++ std string to float Code Example c++ std string to float Code Example
c++ fill array with 0 Code Example c++ fill array with 0 Code Example
c++ encapsulation Code Example c++ encapsulation Code Example
rotate array cpp Code Example rotate array cpp Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10