Alex Rivera | Logout

What happens when hash collision happens in Dictionary key?

Asked 2010-06-04T15:38:32.880
35

I've been coding in c++ and java entirety of my life but on C#, I feel like it's a totally different animal.

In case of hash collision in Dictionary container in c#, what does it do? or does it even detect the collision?

In case of collisions in similar containers in SDL, some would make a key value section link data to key value section like linked list, or some would attempt to find different hash method.

[Update 10:56 A.M. 6/4/2010]

I am trying to make a counter per user. And set user # is not defined, it can both increase or decrease. And I'm expecting the size of data to be over 1000.

So, I want :

  • fast Access preferably not O(n), It important that I have close to O(1) due to requirement, I need to make sure I can force log off people before they are able to execute something silly.
  • Dynamic growth and shrink.
  • unique data.

Hashmap was my solution, and it seems Dictionary is what is similar to hashmap in c#...

Edit
Report

1 Answer

3

Check this link for a good explanation: An Extensive Examination of Data Structures Using C# 2.0

Basically, .NET generic dictionary chains items with the same hash value.

answered 2010-06-04T15:52:52.983

Your Answer