//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的更多相关文章

  1. POJ 3481 Double Queue(STL)

    题意  模拟银行的排队系统  有三种操作  1-加入优先级为p 编号为k的人到队列  2-服务当前优先级最大的   3-服务当前优先级最小的  0-退出系统 能够用stl中的map   由于map本身 ...

  2. Team Queue(STL练习题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1387 Team Queue Time Limit: 2000/1000 MS (Java/Others ...

  3. ZOJ2724_Windows Message Queue(STL/优先队列)

    解题报告 题意: 看输入输出就非常明确. 思路: 优先队列. #include <algorithm> #include <iostream> #include <cst ...

  4. 150723培训心得(queue)

    queue(STL中函数,就是指队列) #include <iostream> #include <queue> using namespace std;        //这 ...

  5. 数组、链表、栈、队列和STL

    数组 数组是一种最基本的数据结构,它是内存上的一块连续存储空间.正因如此数组的随机访问很方便.但数组也有其固有的限制,大小分配后不能改变. STL中的数组 STL中的Array是静态数组模板,就是我们 ...

  6. C++学习注意点

    1.cin,cout关同步再用,不然效率很糟cin,cout关同步再用,不然效率很糟cin,cout关同步再用,不然效率很糟.重要的事情说三遍.关同步代码:std::ios::sync_with_st ...

  7. C语音常用库和函数

    #include <assert.h> //设定插入点 #include <ctype.h> //字符处理 #include <errno.h> //定义错误码 # ...

  8. C/C++头文件一览

    C.传统 C++ #include <assert.h> //设定插入点 #include <ctype.h> //字符处理 #include <errno.h> ...

  9. linux常用头文件

    http://blog.csdn.net/kokodudu/article/details/17361161 aio.h 异步I/Oassert.h 验证程序断言 complex 复数类complex ...

随机推荐

  1. 防止sql注入 查询的sql

    and userName like concat('%',#{userName},'%')

  2. Python快捷键

    IDLE默认不能显示行号,使用ALT+G 跳到对应行号,在右下角有显示光标所在行.列. ALT+P  上一个历史输入内容. ALT+N 下一个历史输入内容. IDLE中按F5可以运行代码.

  3. android下拉刷新控件 android-pulltorefresh

    运行效果: 介绍:ListView.ViewPager.WevView.ExpandableListView.GridView.(Horizontal)ScrollView.Fragment上下左右拉 ...

  4. PHP在浏览器上跟踪调试的方法以及使用ChromePhp、FirePHP的简单介绍

    之前用ThinkPHP时发现有个 trace 函数可以跟踪调试,感觉很有意思,网上搜索了下类似的东西,发现了 ChromePhp ,以前没想过这样来调试 PHP 程序,感觉非常方便,很有用. Thin ...

  5. Facebook FB.init() status参数的作用

    意思是 status 设为 ture 之后调用 FB.getLoginStatus() 不再产生网络请求,数据已经在 FB.init() 调用的时候被请求回来,缓存住了.

  6. 一个数组分四个ul并且每个ul里边有四个li显示

    <?php $a = $array; for($i=0;$i<4;$i++ ) {?> <ul class="new-hover"> <?php ...

  7. Oracle新建实例后,修改sys和system密码。

    sqlplus/nolog connect sys as sysdba alert user sys identified by pwd;

  8. 7、Objective-C中的各种遍历(迭代)方式

    一.使用for循环 要遍历字典.数组或者是集合,for循环是最简单也用的比较多的方法,示例如下: //普通的for循环遍历 -(void)iteratorWithFor { //////////处理数 ...

  9. scala实现快速排序

    scala> def qSort(a: List[Int]): List[Int] = { | ) a | else qSort( a.filter(a.head > _ )) ++ | ...

  10. openvpn环境搭建

    以下为服务端.客户端下载安装包,在CentOS 6.5部署,也可以找到相关下载源 openvpn-2.2.2.tar.gz,openvpn-2.1.3-install.rar,(https://git ...