一.基本概念
和数据结构里面的队列一样,只支持先进先出,队尾插,队头删。
二.基本用法
1.queue对象创建
1. 默认构造函数 | queue<int> q1; |
2. 拷贝构造函数 | queue<int> q2(q1); |
2.queue赋值操作
queue<int> q1;
queue<int> q2;
q2 = q1;
3.queue入队
queue<int> q;
q.push(5); // 5
q.push(4); // 5 4
q.push(3); // 5 4 3
q.push(2); // 5 4 3 2
q.push(1); // 5 4 3 2 1
4.queue入队
q.pop() |
5.queue获取队首
queue<int> q;
q.push(5); cout << q.front() << endl; // 5
6.queue获取队尾
q.back() |
7.queue大小操作
q.empty() |
q.size() |