priority_queue < pair < long long int,pair <long long int ,long long int > > > pq;
In this line of code, I want to form a priority_queue
on the basis of the first long long int
.
The queue pops the min. element.
The std::priority_queue template allows you to specify a type that meets the compare requirement :
typedef mypair pair<long long int, pair<long long int, long long int> >;
std::priority_queue<mypair,
std::vector<mypair>,
std::greater<mypair> > pq;
If all you need is to reverse the order you can std::greater rather than the default std::less . In cases that require a more complex compare function you can implement your own.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.