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)
随机推荐
- javascript 把字符串转换为对象
function strToJson(str) { var json = (new Function("return " + str))(); return json;}
- DB2存储过程语法规则
如何声明一个存储过程CREATE PROCEDURE 存储过程名(IN 输入变量名 输入变量类型,OUT 输出变量名 输出变量类型)紧跟其后的是存储过程属性列表 常用的有:LAN ...
- bzoj 2561: 最小生成树
#include<cstdio> #include<iostream> #include<cstring> #define M 100009 #define inf ...
- bzoj 2244: [SDOI2011]拦截导弹
#include<cstdio> #include<iostream> #include<algorithm> #define M 100009 using nam ...
- POJ 2253 Frogger 最短路 难度:0
http://poj.org/problem?id=2253 #include <iostream> #include <queue> #include <cmath&g ...
- DatagridView的CellLeave光标离开响应事件,实现某列数字自动求和
//光标离开DatagridView,循环获取DatagridView的每一行的第3列的值,相加传给重量 private void dgpz_dataGridView_CellLeave(object ...
- 一看就懂的ReactJs入门教程(精华版)
一看就懂的ReactJs入门教程(精华版) 现在最热门的前端框架有AngularJS.React.Bootstrap等.自从接触了ReactJS,ReactJs的虚拟DOM(Virtual DOM)和 ...
- 【数论+技巧】神奇的Noip模拟试题第二试 T1 素数统计
1. 素数统计 (pcount.pas/.c/.cpp) [问题描述] 小tan的老师揣谙戈给同学们布置了一道题,要求统计给定区间内素数的个数.“这不是很简单吗?”小tan忍不住说.揣谙戈冷 ...
- Android 系统基础
当系统启动一个组件,它其实就启动了这个程序的进程(如果这个进程还未被启动的话)并实例化这个组件所需要的类. 例如,如果你的程序启动了相机程序里的activity去拍照,这个activity实际上是运行 ...
- linux之开发板与宿主机通信--ftp使用
在目标板终端上输入命令: # ftp 192.16.77.66 //192.16.77.66是宿主机IP # cd /home/ //这里可以使用linux命令,但不能使有TAB键 # get ...