Reputation: 11651
I was reading about c++ multimap
and it states that multimap
allows inserting duplicate Keys.This makes me think that a multimap
uses a hashmap
for underneath implementation (since a hashmap allows duplicates incase of collision) then I also read that unordered map
uses a hash map
. My question is then whats the difference between the two. I tried looking for comparison between the two but I could not find anything that would explain this.
Upvotes: 4
Views: 4640
Reputation:
A hash table permits and resolves collisions of hash values. It only stores one copy of each key value (as determined by operator==
or another equality relation). But if two distinct keys hash to the same value (bound to happen), that is handled by collision resolution. For each key, there is a single value.
A multimap is an ADT that associates multiple values with each key instead of one. It's not a particular implementation strategy: It can internally use a hash table, a search tree, or something completely different.
Upvotes: 4