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 ...
随机推荐
- Maven之(一)Maven是什么
首先,Maven的正确发音是[ˈmevən],而不是"马瘟"以及其他什么瘟.Maven在美国是一个口语化的词语,代表专家.内行的意思,约等于北京话中的老炮儿. 一个对Maven比较 ...
- 网站URL重写(Java UrlRewrite 的使用)
现在大部分的网站和商城都会使用到URL重写,接触到这个,也是因为正在做的电子商务商城.URL重写,是将原有的URL采用另一种规则来显示,使得用户方便访问同时也屏蔽一些信息. 在此说下它的好处,在开发过 ...
- python3 数据类型
Python3 中有六个标准的数据类型: Number(数字) String(字符串) List(列表) Tuple(元组) Sets(集合) Dictionary(字典) Number(数字) Py ...
- css3-文字旋转
<meta charset="utf-8"/><style> * {margin: 0; padding: 0;} ul { height: 80px; b ...
- Spring Security(19)——对Acl的支持
目录 1.1 准备工作 1.2 表功能介绍 1.2.1 表acl_sid 1.2.2 表acl_class 1.2.3 表acl_obj ...
- C# 语言规范_版本5.0 (第18章 不安全代码)
1. 不安全代码 **(注:此章对于跨多语言编程开发非常重要,如遇异常无法完成跨语言,建议使用此种方式.) 如前面几章所定义,核心 C# 语言没有将指针列入它所支持的数据类型,从而与 C 和 C++ ...
- php获取url字符串截取路径的文件名和扩展名
<?php //获取连接里边的id $url = 'http://www.rong123.com/cjbkscbsd/x_dfsdfs/24454_1_1.html'; function get ...
- Meta标签中的format-detection属性及含义让IPHONE的数字可以改变颜色
format-detection翻译成中文的意思是“格式检测”,顾名思义,它是用来检测html里的一些格式的,那关于meta的format-detection属性主要是有以下几个设置: meta na ...
- xrange()与range()
range(start,stop,step) range(0,8) >>print range(0,8) [0,1,2,3,4,5,6,7] range()返回一个数字列表. start ...
- Windows Server2012上使用Nginx做文件服务器
由于项目中用到了大量的文件上传和删除,考虑到安全的因素,所以整体的思路是使用FTP从主服务器把文件资源上传到文件服务器上. FTP上传到服务器的代码如下(简单附加一下,具体的网上很多) public ...