Answers for "c++ stl hashmap"

C++
3

hashmap c++

//me 
using namespace std;								//or use std::unordered_map
unordered_map<string,int> map =  {{"one", 1}, {"two", 2}};	//init
map["abc"] = 0;										//insert/change
cout << map["abc"];									//access value
map.erase("abc");									//delete
if (map.find("abc") == map.end()){}					//if 'abc' is not in map
for(auto& i: map){}									//iterate
Posted by: Guest on February-12-2022

Browse Popular Code Answers by Language