STL容器用法速查表:list,vector,stack,queue,deque,priority_queue,set,map
| list | vector | deque | stack | queue | priority_queue |
map |
multimap |
||
| contiguous storage | double-ended queue | LIFO | FIFO | 1st is greatest | |||||
| Iterators | X | X | X | ||||||
| Element access | push_back | push_back | push_back | push | push | push | |||
| push_front | push_front | ||||||||
| pop_back | pop_back | pop_back | pop | pop | pop | ||||
| pop_front | pop_front | ||||||||
| front | front | front | top | front | top | ||||
| back | back | back | back | ||||||
| at(i) | at(i) | at(key) | |||||||
| Modifiers | assign | assign | assign | ||||||
| insert | insert | insert |
insert emplace |
insert emplace(key,val) |
insert
emplace(key,val) |
||||
| erase | erase | erase | erase |
erase(key)=>erasednum erase(it/ita,itb)=>it |
erase(key)=>int(多个)
erase(it/ita,itb)=>it |
||||
| swap | swap | swap | swap | swap(mapb) | swap(mapb) | ||||
| clear | clear | clear | clear | clear() | clear() | ||||
| Capacity | resize | resize | resize | ||||||
| empty | empty | empty | empty | empty | empty | empty | empty() | empty() | |
| Operations | splice | find | find(key)=>it | find(key)=>it(单个) | |||||
| remove | count | count(key) | count(key) | ||||||
| remove_if | equal_range | equal_range | equal_range(pair) | ||||||
| unique | upper_bound | upper_bound | upper_bound | ||||||
| merge | lower_bound | lower_bound | lower_bound | ||||||
| sort | |||||||||
| reverse |
List Operations
| list | splice | // it points to 2 | mylist1: 1 2 3 4 |mylist2: 10 20 30 mylist1.splice (it, mylist2); // mylist1: 1 10 20 30 2 3 4 | mylist2 (empty)|"it" still points to 2 mylist2.splice (mylist2.begin(),mylist1, it); // mylist1: 1 10 20 30 3 4 | mylist2: 2 | "it" is now invalid. mylist1.splice ( mylist1.begin(), mylist1, it, mylist1.end()); //"it" points now to 30 | mylist1: 30 3 4 1 10 20 |
| remove | mylist.remove (value); | |
| remove_if | mylist.remove_if (function); mylist.remove_if(class()); |
|
| unique | bool same_integral_part (double first, double second) { return ( int(first)==int(second) ); } mylist.sort(); // 2.72, 3.14, 12.15, 12.77, 12.77, // 15.3, 72.25, 72.25, 73.0, 73.35 mylist.unique(); // 2.72, 3.14, 12.15, 12.77 // 15.3, 72.25, 73.0, 73.35 mylist.unique (same_integral_part); // 2.72, 3.14, 12.15 // 15.3, 72.25, 73.0 |
|
| merge | first.sort(); second.sort(); first.merge(); first.merge(second,mycomparison); |
|
| sort | ||
| reverse |
STL容器用法速查表:list,vector,stack,queue,deque,priority_queue,set,map的更多相关文章
- java三篇博客转载 详解-vector,stack,queue,deque
博客一:转载自http://shmilyaw-hotmail-com.iteye.com/blog/1825171 java stack的详细实现分析 简介 我们最常用的数据结构之一大概就是stack ...
- HTML5速查表
HTML5速查表 标签 描述 版本 属性 <!--...--> 定义注释 4 / 5 none <!DOCTYPE> 定义文档类型 4 / 5 none <a> 定 ...
- OpenStack 命令行速查表
OpenStack 命令行速查表 updated: 2017-07-18 08:53 Contents 认证 (keystone) 镜像(glance) 计算 (nova) 实例的暂停.挂起.停止 ...
- GNU Emacs命令速查表
GNU Emacs命令速查表 第一章 Emacs的基本概念 表1-1:Emacs编辑器的主模式 模式 功能 基本模式(fundamental mode) 默认模式,无特殊行为 文本模式(text m ...
- 机器学习速查表(cheatsheet)资源汇总分享
本文收集整理了机器学习相关速查表(Machine Learning Cheatsheet),包含机器学习.Python.Numpy.Pandas.Matplotlib.线性代数.微积分.统计学.概率论 ...
- 简明 Git 命令速查表(中文版)
原文引用地址:https://github.com/flyhigher139/Git-Cheat-Sheet/blob/master/Git%20Cheat%20Sheet-Zh.md在Github上 ...
- .htaccess下Flags速查表
Flags是可选参数,当有多个标志同时出现时,彼此间以逗号分隔. 速查表: RewirteRule 标记 含义 描述 R Redirect 发出一个HTTP重定向 F Forbidden 禁止对URL ...
- Markdown 语法速查表
Markdown 语法速查表 1 标题与文字格式 标题 # 这是 H1 <一级标题> ## 这是 H2 <二级标题> ###### 这是 H6 <六级标题> 文 ...
- jQuery API 3.1.0 速查表-打印版
jQuery API 3.1.0 速查表-打印图,(API来自:http://jquery.cuishifeng.cn/index.html)
随机推荐
- J2EE开发实战基础系列一 HelloWorld【转】
开始咱们的第一个程序,首先是配置环境,按照上一章所描述的方式下载开发工具,然后配置Java环境变量,给大家看下具体的结构: 环境变量配置OK的提示,如上图. Eclipse和Tomcat的文件目录 ...
- [转]Visual Studio 2010 单元测试目录
Visual Studio 2010 单元测试共分七个部分: 普通单元测试.顺序单元测试.压力测试,Generic测试.数据库测试.UI界面测试和Web性能测试. 这个系列的博客实例程序可以在下面的链 ...
- Admob(6.12.x)符号未定义错误的解决方法(IOS)
在升级Admob的SDK版本到6.12.x时, 按照官方文档操作(https://developers.google.com/mobile-ads-sdk/docs/#ios), 添加如下framew ...
- CIO谈:基于K2 BPM平台怎么做报销?
即时!可视!可控!高效! 面对报销系统四大业务目标,有一个对策——用K2! 演讲人:沈明 大鹏天然气CIO 查看完章分享内容请关注K2官方微信
- CSU 1160 A(Contest #3)
Description 把十进制整数转换为十六进制,格式为0x开头,10~15由大写字母A~F表示. Input 每行一个整数x,0<= x <= 2^31. Output 每行输出对应的 ...
- 关键字const
const关键字常和指针一起使用. 1,const给读代码的人传达非常有用的信息.比如一个函数的参数是const char *,你在调用这个函数时就可以放心地传给它char *或const char ...
- 网络安全之PHP安全编程建议
要提供互联网服务,当你在开发代码的时候必须时刻保持安全意识.可能大部分 PHP 脚本都对安全问题都不在意,这很大程度上是因为有大量的 无经验程序员 在使用这门语言.但是,没有理由让你因为对你的代码的不 ...
- C#代码 利用MongoDB中Group聚合函数查询
例子: public static void getUserRFM(DateTime beginTime, DateTime endTime) { MongoDat ...
- 单例模式简单解析--Singleton 单例模式(懒汉方式和饿汉方式)
单例模式的概念: 单例模式的意思就是只有一个实例.单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例.这个类称为单例类. 关键点: 1)一个类只有一个实例 这是最基本 ...
- Tab切换栏
// Tab切换栏 function setTab(name, m, n) { for (var i = 1; i <= n; i++) { var menu = document.getEle ...