在C ++ stl中创建Min和Max优先级队列

时间:2015-11-27 07:52:03

标签: c++ stl priority-queue comparator

priority_queue<int, std::vector<int>, std::greater<int> > pq;

更多使用操作数&gt;。这意味着具有更大值的整数应该具有更高的优先级。但是在此优先级队列中,值较小的整数具有较高的优先级。

  priority_queue<int, std::vector<int>, std::less<int> > pq;

less使用操作数&lt;。这意味着值较小的整数应该具有更高的优先级。但是在此优先级队列中,具有更大值的整数具有更高的优先级。

我对他们两个都感到困惑。

0 个答案:

没有答案