Pair inside priority queue

被刻印的时光 ゝ 提交于 2019-12-02 15:56:00

This is what priority_queue looks like:

template<
    class T,
    class Container = std::vector<T>, 
    class Compare = std::less<typename Container::value_type>
> class priority_queue;

In other words, CompareDist should be the third argument and the second argument should be the container (which has value_type), like the following:

priority_queue<pair<int,int>,vector<pair<int,int>>,CompareDist> pq;

Notice also, that priority_queue is what is called a "container adaptor". Another container is used as the underlying container and the priority_queue has special members functions for accessing it. Another example of a container adaptor would be std::stack.

priority_queue<pair<int,int>,vector<pair<int,int>>,CompareDist> pq;

you need to provide second argument for the inbuilt template of priority_queue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!