CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Posts
    3

    class Dictionary

    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.
    Code:
    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.

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: class Dictionary

    Maybe I'm wrong, but I cannot see any question.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  3. #3
    Join Date
    Mar 2008
    Location
    Atlanta, GA
    Posts
    49

    Re: class Dictionary

    Are you trying to figure out what hash function the Hashtable uses? It's probably object.GetHashCode().

  4. #4
    Join Date
    Mar 2008
    Posts
    3

    Re: class Dictionary

    Quote Originally Posted by opedog
    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?

  5. #5
    Join Date
    May 2007
    Posts
    1,546

    Re: class Dictionary

    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.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured