0
为什么优先级队列具有该签名?STL优先级队列构造函数
std::priority_queue<int, std::vector<int>, std::greater<int> > third;
需要什么std::vector<int>
?例如,如果我需要仅在队列中存储队列?
为什么优先级队列具有该签名?STL优先级队列构造函数
std::priority_queue<int, std::vector<int>, std::greater<int> > third;
需要什么std::vector<int>
?例如,如果我需要仅在队列中存储队列?
这些是priority_queue
的模板参数。第二个是用于存储值的后备容器,在这种情况下,您使用vector(这是默认容器)。在上面的例子中,它被传递,以便您可以使用std::greater
更改缺省比较谓词(即,有一个priority_queue
,其中最小值在顶部)。看看类声明here。
哦,好的。非常感谢你的帮助。 – YYY