本文介绍了如何创建Min stl priority_queue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认的stl优先级队列为Max(顶部函数返回最大的元素)。
The default stl priority queue is a Max one (Top function returns the largest element).
为简单起见,它是一个int值优先级队列。
Say, for simplicity, that it is a priority queue of int values.
推荐答案
使用 std :: greater
作为比较函数:
std::priority_queue<int, std::vector<int>, std::greater<int> > my_min_heap;
这篇关于如何创建Min stl priority_queue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!