STL(queue)
双端队列
只能在队的前端进行删除,在队的后端进行插入
只能访问queue容器适配器的第一个和最后一个元素,只能在容器的末尾添加新元素,只能从头部移除元素。
//STL-queue
//queue容器适配器可利用的成员函数链接网站:https://www.cplusplus.com/reference/queue/queue/
#include <iostream>
#include <queue>
#include <list>
using namespace std;
int main()
{
创建一个使用list容器作为基础容器空的vq容器适配器
//queue<int, list<int>>vq1;
//deque<int>d1{ 1,2,3,4,5,6 };
//queue<int>vq2(d1);
//queue<int>vq3(vq2);//等价于queue<int>vq3=vq2
//构建一个queue容器适配器
deque<int>d1{
11, 22, 33, 44, 55 };
queue<int>qd(d1);//11,22,33,44,55
//求出q1存储元素的个数
cout << "\n输出qd容器元素个数为:" << qd.