I am using stl unordered_map and I cannot get the count method to work. This is my program:
typedef unordered_map<char, int> Mymap; int main() { Mymap m; m.insert(Mymap::value_type('a', 1)); m.insert(Mymap::value_type('b', 2)); m.insert(Mymap::value_type('c', 3)); m.insert(Mymap::value_type('b', 4)); m.insert(Mymap::value_type('b', 5)); cout << m.count('b') << endl; return 0; }
The documentation for unordered_map states that unordered_map::count(const Key& k) returns the number of elements with key k . Therefore, I expect the output here to be 3 , while the actual output will be 1 . Why?
Aditya bhatt
source share