Any online reference to priority_queue
http://www.cplusplus.com/reference/stl/priority_queue/ and the include show that the class takes a templated less functor and a default typebase.
So: (without using default template parameters we have):
#include <iostream>
#include <vector>
#include <queue>
int main ()
{
std::priority_queue<int,std::vector<int>,std::less<int> > pqA;
std::priority_queue<int,std::vector<int>,std::greater<int> > pqB;
pqA.push(30); pqB.push(30);
pqA.push(100); pqB.push(100);
pqA.push(25); pqB.push(25);
pqA.push(40); pqB.push(40);
std::cout << "Popping out elements..."<<std::endl;
while (!pqA.empty())
{
std::cout << " " << pqA.top() <<" "<<pqB.top()<<std::endl;
pqA.pop();
pqB.pop();
}
return 0;
}
You can replace less/greater with your own functional if you like, and you can replace vector with any container that has a random access iterator.