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 ...
随机推荐
- 随机love'...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- ios用storyboard快速创建静态cell
在实际开发中经常会遇到下面这样的页面,通常我们用静态cell来做可以快速创建,提高效率 下面讲一下用storyboard创建方法,将一个tableViewController控制器拖入storyboa ...
- robotium测试
作者:贺锐链接:https://www.zhihu.com/question/28466134/answer/40921012来源:知乎著作权归作者所有,转载请联系作者获得授权. 直接用自己的手机上就 ...
- SpringMVC 学习-异常处理 SimpleMappingExceptionResolver 类
Spring3.0 对异常的处理方式总共有两种: 一种是使用 HandlerExceptionResolver 接口,并且 Spring 已经提供默认的实现类 SimpleMappingExcepti ...
- js事件监听-addEventListener (w3c标准) 和 attachEvent(ie)
研究了一个小时,没看懂这两个属性 window.onload = function(){ var oDiv = document.getElementById("J_myDiv") ...
- js 冒泡排序
var arr = []; for(var i=0; i<100000; i++){ arr.push(parseInt(Math.random()*100)) }; var t1 = Date ...
- myeclipse连接数据库oracle
package xsl; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStat ...
- java栈内存堆内存和GC相关
java栈内存堆内存 Java把内存分成两种,一种叫做栈内存,一种叫做堆内存,有着不同的作用.栈内存用来存储局部变量和方法调用.栈内存归属于单个线程,每个线程都会有一个栈内存,其存储的变量只能在其所属 ...
- 在线预览pdf、xlsx、docx、ppt等文档
使用微软提供的Office Online平台只需要一个网址即可在线查看Xls,doc,PPT等文档 http://view.officeapps.live.com/op/view.aspx?src=要 ...
- ACdream 1732
input 样例个数T <=10000 每个样例一个n(2<=n<=10^8) output lcm(1,2,...,n)%2^32 Sample Input 5 ...