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)
随机推荐
- EFCode First 导航属性
首先谈谈自己对EF的接触的过程吧,最先接触EF只是因为EF支持从数据库把关系扒下来,可以省掉自己写Select.Update.Insert这些SQL语句,而且修改非常方便,后来在使用的过程中发现导航属 ...
- java入门第一步之完成jdk的安装(window)【转】
为了面向更多的人类,我决定重温我的java起步: 要进行java开发第一步就是进行java环境的安装,也就是jdk的按装: 1.由于java被oracle收购了,我们下载jdk也就去oracle的官网 ...
- 转 Warning:MongoDB Replica Sets配置注意事项
我们知道,MongoDB不提供单机的数据安全性,取而代之的是提供了Replica Sets的高可用方案.官方文档中提到的案例是三个节点组成的Replica Sets,这样在其中任何一个节点宕机后都会自 ...
- heartbeat安装
wget ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/6rolling/i386/os/Packages/epel-release-6-5 ...
- checkbox 赋值给js 变量
var banuid =[];//定义一个数组 $('input[name="banuid[]"]:checked').each(function(){//遍 ...
- 用for循环打印菱形
package nothh; public class mmm { public static void main(String[] args) { //for循环内的 for按顺序运算,先打印1/4 ...
- EF Code-First数据迁移的尝试
Code-First的方式虽然省去了大量的sql代码,但增加了迁移的操作.尝试如下: 1.首先要在“扩展管理器”里搜索并安装NuGet“库程序包管理器”,否则所有命令都不能识别,会报CommandNo ...
- Chrome 开发者工具有了设备模拟器
今天从哥们那里学到了一个小技巧,使用chrome自带的多设备模拟器来调试页面在不同设备下的显示效果. 特地上网查了一下,记录一下. 如果想要在 Chrome 上测试网站在不同设备,不同分辨率的显示情况 ...
- Problem K 栈
Description A math instructor is too lazy to grade a question in the exam papers in which students a ...
- IE和火狐 差异
1.JavaScript中 1)IE和FireFox中childNodes的差别: <head> <script type="text/javascript"&g ...