Question

MSDN says:

When an element is added to the Hashtable, the element is placed into a bucket based on the hash code of the key.

But I cannot find any information how are buckets organized or created. How are buckets ordered(alphabetically)? What basic principle to create a bucket in a hashtable?

I mean for example, a word "Tom" has a hashcode which is 3. Well, a word "TomTom" has another hashcode, for example, which is 6. My question is in which buckets will these words be putted and why?

Was it helpful?

Solution

How can you not find that basic information? Even Wikipedia has a good explanation? I mean, seriously. This is basic data structures 102 - there are tons of books about it. There are sites about it. Wikipedia describes ton of methods to do that. How the .NET framework does it is not important (implementation detail) as it may change between versions, and even then - the source code is public, so "no information" is wrong again.

For example here you can find the official source code for a 3.5 version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top