The default stl priority queue is a Max one (Top function returns the largest element).
Say, for simplicity, that it is a priority queue of int values.
Use std::greater as the comparison function:
std::greater
std::priority_queue<int, std::vector<int>, std::greater<int> > my_min_heap;
2.1m questions
2.1m answers
60 comments
57.0k users