其他分享
首页 > 其他分享> > unordered_map

unordered_map

作者:互联网

无序map容器
对于有顺序要求的问题,map会更高效一些
对于查找问题,unordered_map会更加高效一些

#include <iostream>
#include <unordered_map>

int main()
{
   std::unordered_map<int, std::string> umap;

   umap.emplace(1, "furong");
   umap.emplace(5, "quange");
   umap.emplace(3, "zhangsan");

   std::cout << "umap size = " << umap.size() << std::endl;

   for (auto iter = umap.begin(); iter != umap.end(); ++iter)
   {
       std::cout << iter->first << " " << iter->second << std::endl;
   }

   return 0;
}
$ ./a.out 
umap size = 3
3 zhangsan
5 quange
1 furong

标签:map,emplace,quange,furong,umap,unordered
来源: https://www.cnblogs.com/zhangxuechao/p/16659192.html