T
thomas
priority_queue usually uses the greater<int> predicate function.
But as you know, we don't always use priority_queue<int>. Actually we
may need the "priority_queue<pair<int,int>, vector<pair<int,int> >,
cmp> hp;" thing.
My question is how should I write the "cmp" function?
I tried this one:
bool cmp(pair<int,int> &x, pair<int,int> &y){
return x.second < y.second;
}
but it doesn't work while it usually makes sense for "sort" predicate.
Any comments? Thanks in advance.
But as you know, we don't always use priority_queue<int>. Actually we
may need the "priority_queue<pair<int,int>, vector<pair<int,int> >,
cmp> hp;" thing.
My question is how should I write the "cmp" function?
I tried this one:
bool cmp(pair<int,int> &x, pair<int,int> &y){
return x.second < y.second;
}
but it doesn't work while it usually makes sense for "sort" predicate.
Any comments? Thanks in advance.