前言:
STL是Standard Template Library的简称,中文名标准模板库,惠普实验室开发的一系列软件的统称。它是由Alexander Stepanov、Meng Lee和David R Musser在惠普实验室工作时所开发出来的。从根本上说,STL是一些“容器”的集合,这些“容器”有list,vector,set,map等,STL也是算法和其他一些组件的集合。这里的“容器”和算法的集合指的是世界上很多聪明人很多年的杰作。STL的目的是标准化组件,这样就不用重新开发,可以使用现成的组件。STL现在是C++的一部分,因此不用安装额外的库文件。
STL的版本很多,常见的有HP STL、PJ STL、 SGI STL等。
在C++标准中,STL被组织为下面的13个头文件:<algorithm>、<deque>、<functional>、<iterator>、<vector>、<list>、<map>、<memory.h>、<numeric>、<queue>、<set>、<stack>和<utility>。
1、map库
先记录,有空再整理:
https://blog.csdn.net/sevenjoin/article/details/81943864
#include <iostream>
#include <queue>
#include <map>
using namespace std;
//map的查找功能测试
void map_find(map<int,string>* m,int num){
//查找
map<int,string>::iterator it=m->find(num);//因为这里的m是指针,所以需要用->
if(it!=m->end()){
cout<<"m.first= "<<it->first<<endl;
cout<<"m.second= "<<it->second<<endl;
}else{
cout<<"can not find"<<endl;
}
}
int main()
{
map<int,string> m;
map<int,string>* t=&m;
m.insert(pair<int,string>(1,"xixi"));
m.insert(pair<int,string>(2,"hehe"));//不会覆盖
m[3]="keke";//会覆盖
map_find(t,1);
getchar();
}
2、pair对组
3、 list
版权声明:本文为weixin_37058227原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。