Priority queue in reverse order
c++, priority-queue, std
Solution
You can't avoid specifying the storage container, but you can avoid writing your own functor:
priority_queue<int, vector<int>, std::greater<int> > first;
Problem
This site suggests that if I want to reverse-order my priority queues, the following code is what I should use: ``` #include <iostream> #include <queue> using namespace std; class mycomparison{ bool reverse; public: mycomparison(const bool &revparam=false) {reverse=revparam;} bool operator() (const int &lhs, const int &rhs) const { if (reverse) return (lhs>rhs); else return (lhs<rhs); } }; int main (){ int myints[]= {10,60,50,20}; priority_queue<int, vector<int>, mycomparison(true)> first; return 0; } ``` This bothers me: - I have to specify the storage class in my constructor. - I have created a class whose only purpose is to be passed to the priority queue. Is there a more elegant or less verbose way of reverse-sorting a priority queue?