📜  如何在 C++ 代码示例中的优先级队列中使用比较器功能

📅  最后修改于: 2022-03-11 14:44:51.466000             🧑  作者: Mango

代码示例1
// suppose you want to apply comparator on pair 
// declaration of priority queue
priority_queue, vector>, myComp> pq;
// here myComp is comparator
struct myComp {
  bool operator()(
    pair& a,
    pair& b)
  {
    return a.first > b.first;
    // can write more code if required. depends upon requirement.
  }
};