头文件是<queue>
操作很简单
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
int main()
{
// 默认定义最大值优先级队列
priority_queue<int> p1;
p1.push(12);
p1.push(44);
p1.push(4);
cout<<p1.top()<<endl;
p1.pop();
cout<<p1.top()<<endl;
// 最小值优先级队列
priority_queue<int,vector<int>,greater<int>> p2;
p2.push(3);
p2.push(5);
p2.push(1);
cout<<p2.top()<<endl;
p2.pop();
cout<<p2.top()<<endl;
return 0;
}
来源:https://www.cnblogs.com/jishuren/p/12241171.html