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)
随机推荐
- sql删除多余重复的数据只保留一条
delete from people where peopleName in (select peopleName from people group by peopleName ...
- javascript——拖拽(完整兼容代码)
拖拽,是JS经常会用到的效果,在网上有很多的这样那样的拖拽效果,但其中往往大多有各种各养的问题,功能不全,无法兼容,而且修改的时候 也是十分麻烦. 其实拖拽的原理很简单,无非是鼠标的三个动作的解析,以 ...
- xml数据解析调研
XML数据解析http://www.tuicool.com/articles/Nraau2(必用) http://www.cnblogs.com/pengyingh/articles/2342699. ...
- bzoj 2744: [HEOI2012]朋友圈
#include<cstdio> #include<iostream> #define M 3010 using namespace std; ],u[M*M>>] ...
- 二模 (5)day1
第一题: 题目大意:解一元一次方程(只有+-符号): 解题过程:直接处理处两边的x的系数和常数项,字符串的处理即可. 第二题: 题目大意:求逆序对数. 解题过程:直接归并排序. 第三题: 题目大意:多 ...
- IBatis.net动态SQL语句(六)
在学习动态SQL语句之前,首先必须对条件查询有一定了解,先来学习如何向IBatis.Net的映射文件里传入参数. 一.条件查询 1.传递单个参数 如根据Id查询: <select id=&quo ...
- NAND驱动
NAND FLASH是一个存储芯片 那么: 这样的操作很合理"读地址A的数据,把数据B写到地址A" 问1. 原理图上NAND FLASH和S3C2440之间只有数据线, ...
- IE9的css hack
以前写过<IE8的css hack>,ie9一出css hack也该更新,以前一直没关注,今天在内部参考群mxclion分享了IE9的css hack,拿出来也分享一下: select { ...
- Android之sdcard操作
private static final String FILENAME = "abc.txt"; private static final String DIR = " ...
- 关于Spatial referencing by geographical identifiers 标准
地理信息空间参考大体可以分为两类,ISO给出了分类:Spatial referencing by geographical identifiers(根据地理标识符的空间定位,ISO 19112)与Sp ...