Click to See Complete Forum and Search --> : class Dictionary


madsiro
April 20th, 2008, 03:13 PM
Hi, I'm programming in C #, and I have a question about the class dictionary, I know that this work as a hash table, but I would like to know how that hash function uses (or which is the one that could use), and that size is its table, here is an example of Dictionary, and here is my question.

private static Dictionary<string, double> PrepareFrequency(string[] words)
{
Dictionary<string, double> table = new Dictionary<string, double>();

foreach (string word in words)
{
if (table.ContainsKey(word))
table[word]++;
else
table.Add(word, 1);
}

return table;
}

Thanks for your attention.

boudino
April 21st, 2008, 01:57 AM
Maybe I'm wrong, but I cannot see any question.

opedog
April 21st, 2008, 07:19 AM
Are you trying to figure out what hash function the Hashtable uses? It's probably object.GetHashCode().

madsiro
April 21st, 2008, 12:20 PM
Are you trying to figure out what hash function the Hashtable uses? It's probably object.GetHashCode().
My question is: What function dispersion could be using Dictionary?

Mutant_Fruit
April 21st, 2008, 12:27 PM
The hashcode is an int which is calculated in the Object.GetHashcode() function which every object has. It can also be overridden by the user to provide a custom implementation. There is no standard implementation.