Working with Dictionaries

mtillettmtillett Member Posts: 7 ■□□□□□□□□□
I am not sure if I have missed something, but I am trying to figure out why you would ever use a Hashtable or a ListDictionary when you have a HybridDictionary.

ListDictionarys are for small lists, Hashtables are for large, but HybridDictionarys start as a ListDictionary and when the list is large enough they auto upgrade themselves to a HashTable.

Is there a performance issue or something because I cannot see why you would ever use the HashTable or ListDictionary when you have a HybridDictionary.

Many thanks,
Mat

Comments

  • bcairnsbcairns Member Posts: 280
    Hashtables have been around since the birth of .Net (longer if you talk about other languages).

    Hashtable = dictionary of objects

    ListDictionarys = an array good performance on small lists

    HybridDictionarys = an advanced version of the ListDictionary, a class that upgrades the from a Array to a Dictionary object.

    In sort most people will use a hashtable because it has been around forever.

    That and most of the .net 1.0 developers dont know about the ListDictionarys and HybridDictionarys.
  • JDMurrayJDMurray Admin Posts: 13,097 Admin
    Hmmmm...it looks like Lists, ArrayLists, Hashtables, ListDictionarys, and HybridDictionarys would be a good first exam topic study thread for this forum.
  • mtillettmtillett Member Posts: 7 ■□□□□□□□□□
    I did some followup testing counting the ticks passed during a lookup and found that listdictionarys are definitely faster with small lists and hashtables are faster for large lists. Adding a hybriddictionary has a performance hit and is without doubt the slowest of the three.

    In my opinion, only use a hybriddictionary when you are truly unsure of the list size.
    Mat
Sign In or Register to comment.