STL学习----入门(1)[queue]
2015-08-24 18:36
369 查看
#include<queue>:
队列(Queue)是一个容器适配器(Container adaptor)类型,被特别设计用来运行于FIFO(First-in first-out)场景,在该场景中,只能从容器一端添加(Insert)元素,而在另一端提取(Extract)元素。
容器所包含的元素的类型。
在类模板内部,使用其别名为 value_type 的成员类型。
Container
底层的用于存储元素的容器的类型。
用来实现队列的底层容器必须满足顺序容器的所有必要条件。同时,它还必须提供以下语义的成员函数:
front()
back()
push_back()
pop_front()
满足上述条件的标准容器有
std::deque
及 std::list,如果未特别指定
queue 的底层容器,标准容器 std::deque 将被使用。
Any sequence container supporting operations front(), back(), push_back() and pop_front() can be used to instantiate queue. In particular, list and
deque can be used.
Element access:
Capacity:
Modifiers:
// <queue> template < class T, class Container = deque<T> > class queue;
队列(Queue)是一个容器适配器(Container adaptor)类型,被特别设计用来运行于FIFO(First-in first-out)场景,在该场景中,只能从容器一端添加(Insert)元素,而在另一端提取(Extract)元素。
模板参数
T容器所包含的元素的类型。
在类模板内部,使用其别名为 value_type 的成员类型。
Container
底层的用于存储元素的容器的类型。
详细说明
queue 通常被实现为容器适配器,即使用一个特定容器类的封装对象作为它的底层容器。queue 提供了一系列成员函数用于操作它的元素,只能从容器“后面”压进(Push)元素,从容器“前面”提取(Pop)元素。用来实现队列的底层容器必须满足顺序容器的所有必要条件。同时,它还必须提供以下语义的成员函数:
front()
back()
push_back()
pop_front()
满足上述条件的标准容器有
std::deque
及 std::list,如果未特别指定
queue 的底层容器,标准容器 std::deque 将被使用。
Any sequence container supporting operations front(), back(), push_back() and pop_front() can be used to instantiate queue. In particular, list and
deque can be used.
成员类型
成员类型 | 定义 |
---|---|
value_type | 第一个模板参数 T |
container_type | 第二个模板参数 Container |
size_type | Container::size_type |
reference | Container::reference |
const_reference | Container::const_reference |
成员函数
(constructor) | 创建 queue |
(destructor) | 释放 queue |
operator= | 赋值操作 |
front | 访问第一个元素 |
back | 访问最后一个元素 |
empty | 判断是否为空 |
size | 返回有效元素个数 |
push | 在容器顶部插入元素 |
pop | 移除容器顶部的元素 |
emplace C++11 | 在容器顶部放置插入元素 |
swap | 交换容器的内容 |
非成员函数
operator==、operator!=、operator<、operator<=、operator>、operator>= | 关系操作符 |
std::swap | 交换两个队列的内容 |
相关文章推荐
- 野人学Android基础篇之初探UI控件第一课--TextView静态赋值
- The Dole Queue(UVA 133)
- IOS第12天(1,UIViewController控制器的创建的 三种方式,和第一个view创建)
- 百度编辑器ueditor简单易用
- UI19_数据库
- iOS开发UI篇—CAlayer层的属性
- 如何自己编译apue.3e中代码 & 学习写makefile
- android stuido插件
- 【POJ 2031】 Building a Space Station (三维坐标求距离+最小生成树)
- IOS-6-UI知识总结-1(代码添加控件、视图切换、多种传值方式)
- iOS下UITableView的单元格重用逻辑
- 总结Android UI 自动化测试
- TableViewCell添加2个和多个侧滑菜单按钮
- leetcode 187: Repeated DNA Sequences
- AS3 URLRequest相关,浏览器请求头MIME类型引发的问题
- 类似与fiddler的抓包工具 burp suite free edition
- iOS开发-Day29-UI UIScrollView&多视图
- POJ3210 a stack or a queue
- MII、GMII、RMII、SGMII、XGMII、XAUI、Interlaken
- DuiLib : 使用CListUI显示海量数据