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)
随机推荐
- 0302IT行业就业&软件工程之我所思和所想
阅读以下文章 http://www.thea.cn/news/terminal/9/9389.html http://www.shzhidao.cn/system/2015/09/22/0102610 ...
- 常见JS(JavaScript)冲突解决方法
1.一般JS冲突解决办法 a.最容易出现的就是js的命名冲突 ①.变量名冲突 变量有全局变量和局部变量当全局变量变量和局部变量名称一致时,就会js冲突,由于变量传递数值或地址不同就会产生JavaScr ...
- P121 6.7 第一题和第二题
package nothh; import java.util.Arrays; public class shuzu6_7 { public static void main(String[] arg ...
- 完美实现自己的GetProcAddress函数(转载)
我们知道kernel32.dll里有一个GetProcAddress函数,可以找到模块中的函数地址,函数原型是这样的: WINBASEAPI FARPROC WINAPI GetProcAddress ...
- 关于http断点续传相关的RANGE这个header
<?php //1.txt内容"1234567890" socketData('127.0.0.1','/1.txt',80,"RANGE:bytes=0-0\r\ ...
- ASP.NET MVC学习之控制器篇(二)
原文链接:http://www.asp.net/learn/mvc/ 这篇教程探索了ASP.NET MVC控制器(controller).控制器动作(controller action)和动作结果(a ...
- TDBGridEh的 搜索面板 TDBGridSearchPanel
TCustomDBGridEh.Create FSearchPanelControl := TDBGridSearchPanelControlEh.Create(Self); //这里,创建的构造函数 ...
- 神州通,我看行---K2用户交流会华南站
主题:K2高级移动信息化解决方案DBToApp开发工具 嘉宾:神州通在线 张德阔 移动办公APP开发≠一般APP开发,你知道这几种企业管理移动APP开发模式吗? 原生APP开发模式Native 具有最 ...
- Problem C HDU 5224
Description There is a piece of paper in front of Tom, its length and width are integer. Tom knows t ...
- android listview getviewtypecount和getItemViewType
package newdemo.jeno.listviewdemo; import android.app.Activity;import android.os.Bundle;import andro ...