queue STL
//queue STL
//queue is just a container adaptor, which is a class that use other container.
//just like stack
q1.push(x) //push x into the queue
q1.pop() //pop the first element in the queue
q1.front() //return the first element in the queue
q1.back() //return the last element in the queue
q1.empty()
q1.size() //C++11
q1.emplace(x) //add a new element at the end of the queue, after its current last element //the differences between emplace and push
//though they are both the functions to add elements in the queue
//if you use emplace ,you will not make a new class.
//Let's see a example
struct node
{
int x, y; node(int a, int b) :x(a), y(b){}
}; int main()
{
queue<node>q1,q2;
q1.emplace(1, 2);
q2.push(node(1, 2)); cout << q1.front().x << endl; return 0;
}
queue STL的更多相关文章
- POJ 3481 Double Queue(STL)
题意 模拟银行的排队系统 有三种操作 1-加入优先级为p 编号为k的人到队列 2-服务当前优先级最大的 3-服务当前优先级最小的 0-退出系统 能够用stl中的map 由于map本身 ...
- Team Queue(STL练习题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1387 Team Queue Time Limit: 2000/1000 MS (Java/Others ...
- ZOJ2724_Windows Message Queue(STL/优先队列)
解题报告 题意: 看输入输出就非常明确. 思路: 优先队列. #include <algorithm> #include <iostream> #include <cst ...
- 150723培训心得(queue)
queue(STL中函数,就是指队列) #include <iostream> #include <queue> using namespace std; //这 ...
- 数组、链表、栈、队列和STL
数组 数组是一种最基本的数据结构,它是内存上的一块连续存储空间.正因如此数组的随机访问很方便.但数组也有其固有的限制,大小分配后不能改变. STL中的数组 STL中的Array是静态数组模板,就是我们 ...
- C++学习注意点
1.cin,cout关同步再用,不然效率很糟cin,cout关同步再用,不然效率很糟cin,cout关同步再用,不然效率很糟.重要的事情说三遍.关同步代码:std::ios::sync_with_st ...
- C语音常用库和函数
#include <assert.h> //设定插入点 #include <ctype.h> //字符处理 #include <errno.h> //定义错误码 # ...
- C/C++头文件一览
C.传统 C++ #include <assert.h> //设定插入点 #include <ctype.h> //字符处理 #include <errno.h> ...
- linux常用头文件
http://blog.csdn.net/kokodudu/article/details/17361161 aio.h 异步I/Oassert.h 验证程序断言 complex 复数类complex ...
随机推荐
- 运行机制和JVM
Java代码编译后生成一种与平台无关的字节码(也就是class文件).当然,这种字节码不是可执行的,必须使用Java解释器来解释执行. 负责解释执行字节码文件的是Java虚拟机,即JVM.JVM是可运 ...
- MVC-Area
ASP.NET MVC中,是依靠某些文件夹以及类的固定命名规则去组织model实体层,views视图层和控制层的.如果是大规模的应用程序,经常会由不同功能的模块组成,而每个功能模块都由MVC中的三层所 ...
- 面试题-Java基础-布局管理器
1.什么是布局管理器? 布局管理器用来在容器中组织组件.
- OBIEE 缓存机制
1,EM下开关缓存和rpd中高速缓存是一件事,就是nqserver的缓存, 由nqsconfig.ini中配置决定cache是否开启. 当然rpd里面还需要设置,具体的表是否要缓存. 这部分可以看这篇 ...
- C#数字类型及运算符
- tomcat服务配置及搭建
一.在官网上下载tomcat 下载地址:http://tomcat.apache.org/download-60.cgi 下载完后解压 二.设置环境变量 1,JAVA_HOME 2.CATALINA_ ...
- [DP之普通系列]
noip快要来了 要练练dp 难度也挺接近 还是挺好的 [Usaco2013 Nov]Pogo-Cow 这一道题要下一段大于这一段 所以的话我们就要记录每一段的状态 F[i,j]=F[j,k]+A[i ...
- [DP优化方法之斜率DP]
什么是斜率dp呢 大概就把一些单调的分组问题 从O(N^2)降到O(N) 具体的话我就不多说了 看论文: http://www.cnblogs.com/ka200812/archive/2012/08 ...
- 【锋利的Jquery】读书笔记一
封面镇楼: 读这本书应该是7月份,二周读完,经典的好书,一直没怎么复习.so....温故而知新下. 一.jquery的风格 链式风格 <div class="box"> ...
- CentOS7中将Mysql添加为系统服务
如果是自己通过tar包安装的Mysql,不会自动添加到系统服务中,可通过如下方式,自己添加. 先启动一下mysql ${mysql}/support-files/mysql.server start ...