-
unordered_map
#include<unordered_map>
unordered_map<int, int> m;
m[16]=1;//初始化
m.find(16) != m.end();//查找
unordered_map<int,int>::iterator it;
it = m.find(16);
int first = it->first;
int second = it->second;
int cnt=m.count(16);//查找有几个16
-
unordered_set
#include<unordered_set>
unordered_set<int> set;
set.insert(5);//插入
set.erase(5);//删除
set.insert(6);
int cnt = set.count(5);//查询数量,只有1或0
set.clear();
Comments | 0 条评论