Horje
how to use comparator funtion in priority queue in c++ Code Example
how to use comparator funtion in priority queue in c++
// suppose you want to apply comparator on pair <int, string>
// declaration of priority queue
priority_queue<pair<int, string>, vector<pair<int, string>>, myComp> pq;
// here myComp is comparator
struct myComp {
  bool operator()(
    pair<int, string>& a,
    pair<int, string>& b)
  {
    return a.first > b.first;
    // can write more code if required. depends upon requirement.
  }
};




Cpp

Related
how to make crypto Code Example how to make crypto Code Example
infinity c++ Code Example infinity c++ Code Example
BAPS Code Example BAPS Code Example
how to get 4 decimal places in c++ Code Example how to get 4 decimal places in c++ Code Example
bold text latex Code Example bold text latex Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12