Posts

Showing posts with the label hashmap

map vs. hash_map in C++

Image
map vs. hash_map in C++ I have a question with hash_map and map in C++. I understand that map is in STL, but hash_map is not a standard. What's the difference between the two? hash_map map map hash_map 6 Answers 6 They are implemented in very different ways. hash_map ( unordered_map in TR1 and Boost; use those instead) use a hash table where the key is hashed to a slot in the table and the value is stored in a list tied to that key. hash_map unordered_map map is implemented as a balanced binary search tree (usually a red/black tree). map An unordered_map should give slightly better performance for accessing known elements of the collection, but a map will have additional useful characteristics (e.g. it is stored in sorted order, which allows traversal from start to finish). unordered_map will be faster on insert and delete than a map . unordered_map map unordered_map map ...