I couldn't get the comparator in std:: priority_queue.
std::priority_queue<pii, std::vector<pii >, myComparator> pq;
using:
class myComparator
{
public:
int operator() ( const ppi &p1, const ppi &p2 )
{
return p1 . second > p2 . second;
}
};
here ppi is
#define ppi std::pair<std::pair<int, int>,int>
And how it is different from the comparator in std:: sort. Below work for std:: sort but no for std:: priority_queue
bool myComparator ( const pii &p1, const pii &p2 )
{
return p1 . second > p2 . second;
}
Aucun commentaire:
Enregistrer un commentaire