C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL) 2笔记
来源:互联网 发布:java获取编码方式 编辑:程序博客网 时间:2024/06/06 02:50
#include <functional>//c++11#include<algorithm>//包括,remove and erase#include<iostream>#include<map>#include <ostream>#include<unordered_map>#include <string>#include <vector>using namespace std;/*-----------------------map的基本使用int main(){map<int,string> m;m[1]="one";m[2]="two";m[4]="four";m[3]="three";m[2]="TWO!";//cout<<m[2]<<endl;//right:for (auto i=m.begin();i!=m.end();++i){cout<<i->first<<" "<<i->second<<endl;}m.clear();}-------------------------------*//*------------------------------------------map在函数中的调用相关,不明问题1void foo(const map<int,string> &m){//m[7]="seven";//false;m is constcout<<m[3]<<endl;// wrong:DONT KNOW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!map<int,string>::const_iterator i=m.find(3);if (i==m.end()){cout<<"Not Found"<<endl;} else{cout<<i->second<<endl;}}int main(){map<int,string> m;m[1]="one";m[2]="two";m[4]="four";m[3]="three";m[2]="TWO!";//cout<<m[2]<<endl;//right:foo(m);for (auto i=m.begin();i!=m.end();++i){cout<<i->first<<" "<<i->second<<endl;}m.clear();}---------------------------------------*//*--------------------------------------boost库中的map ,按照hash_value判断,问题1,什么是hash_valueint main(){unordered_map<int,string> m;m[1]="one";m[2]="two";m[4]="four";m[3]="three";m[2]="TWO!";//cout<<m[2]<<endl;//right:for (auto i=m.begin();i!=m.end();++i){cout<<i->first<<" "<<i->second<<endl;}m.clear();}-------------------------*//*----------------------------c++11 包含 functional头文件后的使用,以后补充int main(){map<int,string,greater<int>> m;m[1]="one";m[2]="two";m[4]="four";m[3]="three";m[2]="TWO!";//cout<<m[2]<<endl;//right:for (auto i=m.begin();i!=m.end();++i){cout<<i->first<<" "<<i->second<<endl;}m.clear();}-------------------------------*//*-----------------------------使用functional 和 algorithm,对函数内容进行删减int main(){vector<int> v;v.push_back(11);v.push_back(22);v.push_back(33);v.push_back(44);v.push_back(55);v.erase(remove_if(v.begin(),v.end(),[](int e){return e%2==1;}),v.end());for (auto i=v.begin();i!=v.end();++i){cout<<*i<<endl;}v.clear();}--------------------------------------*/
0 0
- C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL) 2笔记
- STL(Standard Template Library)
- STL(Standard Template Library)
- STL(Standard Template Library)总结
- STL(Standard Template Library)简介
- STL(Standard Template Library)简介
- Standard Template Library (STL)基础
- STL(Standard Template Library)
- 算法笔记:C++ STL(Standard Template Library)
- 标准模板库STL(Standard Template Library )2
- STL(Standard Template Library)适配容器
- STL(Standard Template Library)(一)
- 标准模板库STL(Standard Template Library)
- C++11/14/17 Features In VS 2015 Preview(Stephan T. Lavavej)
- 算法笔记:C++ STL(Standard Template Library)二(未完待续)
- STL (Standard Template Library)标准模板库 C++
- 什么是STL(Standard Template Library,标准模板库)
- C++,VC++,MFC,STL(standard template library,标准模板库)
- 浅谈 PHP 服务器性能优化配置
- ICP in VTK
- 线程Thread join 方法---优先执行
- 奇偶位互换 2562
- NYOJ-119 士兵杀敌(三 。 rmq
- C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL) 2笔记
- Nyoj 195
- 函数名的隐式转换
- 【Unity Shaders】Reflecting Your World —— 在Unity3D中创建Cubemaps
- [运营经验] X3.1搬家完美详细教程教程,亲测
- 关于python文件操作
- 态度很重要
- C++中数字与字符串之间的转换
- 浅谈 C++ 中的 new/delete 和 new[]/delete[]