how can unordered maps in stl have duplicate keys because we are usng a hasg function that calculates the lenbgth of full name to hash the key and still it is storing “rahul” two times but the length of name is same
Doubt in unordered maps
hello @Aryanchugh223
unordered map dont allow duplicate keys reason you know already.
we have something called multimap/multiset there we can have duplicates keys .because they are not implemented using hashtable.
they are implemented using self balancing tree i think it is red black.
But then how in the STL video section of unordered maps for custom objects (student class) we are able to store two students with same name, different roll numbers.
And the custom hash function that we gave was length of name.
So the hash function will generate same integer for both the entries
Then how are they both getting stored.
which video u are referring to can u please name it.
Unordered Map - Hash Function for Custom Class
to resolve collision separate chaining is used in case of unordered map.
so in that case
we will have same key and multiple value.
something like
key -> value1,value2,value3,value4
so in this way we are handling the case of collision
Okay thankyou
That cleared my doubt 
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.