map
作者:互联网
unordered_map<int,int>a;
unordered_map<int ,int>::iterator it;
it=a.find(8);
if(it==a.end())chu("no");
find找的是前面的键值
unordered_map<int,int>mymap;unordered_map<int,int>mymap; unordered_map<int,int>::iterator it; mymap[1]=2; mymap[2]=5; for ( it = mymap.begin(); it != mymap.end(); ++it ) chu("%d %d\n",it->first,it->second); std::cout << std::endl; 循环遍历所有元素 return 0;
for ( auto it = mymap.begin(); it != mymap.end(); ++it ) std::cout << " " << it->first << ":" << it->second; std::cout << std::endl;
标签:std,map,end,cout,mymap,unordered 来源: https://www.cnblogs.com/403caorong/p/16522527.html