1.按照从大到小进行排序
priority_queue<int>q1;
priority_queue<int,vector<int>,less<int> >q2;//注意less<int>和最后一个>要加空格分隔开
struct infor{
int a,b;
friend bool operator < (infor x,infor y){
return x.a < y.a;
}
}
priority_queue<infor>q3;
struct infor{
int a,b;
bool operator < (const infor &x) const{
return a < x.a;
}
}
priority_queue<infor>q4;
struct cmp1{
bool operator()(int &a,int &b){
return a < b;
}
}
priority_queue<int,vector<int>,cmp1>q5;
2.从小到大进行排序:
priority_queue<int,vector<int>,greater<int> >q6;
struct infor{
int a,b;
friend bool operator < (infor x,infor y){
return x.a > y.a;
}
}
priority_queue<infor>q7;
struct infor{
int a,b;
bool operator < (const infor &x) const{
return a > x.a;
}
}
priority_queue<infor>q8;
struct cmp2{
bool operator()(int &a,int &b){
return a > b;
}
}
priority_queue<int,vector<int>,cmp2>q9;