#include<iostream>
#include<vector>
#include<ctime>
#include<deque>
#include<list>
#include<algorithm>
#include<queue>
#include<functional>//greater使用
using namespace std;
void print(deque<int> a) {
for (int i = 0; i < a.size(); i++) {
cout << "a[" << i << "]=" << a[i] << endl;
}
}
int main() {
//STL 容器 算法 迭代器
//queue是一个容器适配器,不是原始的容器类型
//原始的容器类型有:vector,deque,list
//queue(自适应容器:容器适配器)
//queue:用list做queue:用deque做queue:不能用vector做queue
queue<int, deque<int>> a;
queue<int, list<int>> b;
queue<int> c;//不写默认是deque
//STL 优先级队列 priority__queue:始终就是在队列的最前边
//不是先进先出的
//自适应容器适配器:不能用list(对数据进行随即操作,list不能随机)
//最大值优先级队列、最小级优先级队列
cout << "最大级优先级队列----------
" << endl;
priority_queue<int, vector<int>> pq;//默认是vecor
//priority_queue<int, deque<int>> pq2;
pq.push(10);
pq.push(10);
pq.push(5);
pq.push(-1);
pq.push(20);
while (!pq.empty()) {
cout << "从队列优先级里删除" << pq.top() << endl;
pq.pop();
}
cout << endl;
cout << "最小级优先级队列----------
" << endl;
//最小优先级队列
priority_queue<int, deque<int>, greater<int>> qpq2;
qpq2.push(10);
qpq2.push(10);
qpq2.push(5);
qpq2.push(-1);
qpq2.push(20);
while (!qpq2.empty()) {
cout << "从队列优先级里删除" << qpq2.top() << endl;
qpq2.pop();
}
system("pause");
}