std::unordered_map 怎么查找
时间: 2023-04-04 11:02:45 浏览: 98
HashmapBenchmark:子弹哈希映射(btHashMap)和C++标准库哈希映射(std)之间的基准测试
std::unordered_map 可以使用 find() 函数进行查找,例如:
std::unordered_map<std::string, int> myMap;
myMap["apple"] = 1;
myMap["banana"] = 2;
auto it = myMap.find("apple");
if (it != myMap.end()) {
std::cout << "apple is found with value " << it->second << std::endl;
} else {
std::cout << "apple is not found" << std::endl;
}
输出结果为:
apple is found with value 1
阅读全文