#include <set>
集合,包含的是无序集合,基本同数学中集合的概念,不存在重复元素。
存在以下几种操作:
insert(key);插入键值key
insert(iterator_ first,iterator_last);插入迭代器在first和last之间的值;
clear();
size();
begin();
end();
erase(key);
find(key);
count(key);查询key在集合中加入了几次;
#include <map>
是一个以键和值对应关系为元素的一个集合,类似于字典,每一对元素可以看做是一组pair,存在以下几种操作:
insert((key,value));也可以插入insert(x); x是一个pair;也可以直接定义A["fuck"]=4;
clear();
size();
begin();
end();
erase(key);
find(key);
#include <utility>
pair是一组对应关系,类似于
struct pair{
class first;
class second;
};
构造函数是make_pair(first,second);
可以如下调用
pair<string,int> a("love",4);
cout<<a.first<<" "<<a.second<<endl;//output is love 4