ywrby

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

queue容器

队列容器 先进先出

在这里插入图片描述

特性:

  1. 不能进行遍历
  2. 不提供迭代器
  3. 不支持随机访问

#include<iostream>
#include<queue>
using namespace std;

void queueTest1() {
	queue<int> q;  //创建队列
	
	q.push(10);  //元素入队
	q.push(20);
	q.push(30);
	q.push(40);
	q.pop();  //元素出队
	while (!q.empty()) {
		cout << q.front() << endl;
		q.pop();
	}
	cout << "size = " << q.size() << endl;
	  
}


int main() {
	queueTest1();
	return 0;
}
posted on 2020-02-20 20:05  ywrby  阅读(129)  评论(0)    收藏  举报