What is the fastest collection class?

  • Thread starter Thread starter john
  • Start date Start date
J

john

I need to use a class that is a collection of objects where I can do a
comparing operation like this:

col = new FastCollectionClass();
bool b = col.IsThisItemAlreadyInTheCollection(obj);

Where the function to see if an object is already in the collection is
fast. I was thinking of using a HashTable even though I don't need to
use the "key" part of the dictionary since I know HashTables are
designed for fast lookup. Any ideas of better classes to use?

thanks in advance,
John
 
If you use the HybridDictionary you get better speed under
a certain threshold of elements (not sure what internal
threshold is used, but ILDasm might reveal it).

But still, the Hashtable is fast. If you do use it, call
one of the constructors with the "loadFactor" parameter.
Setting this value to it's miniumum (0.1f) will give you
faster lookups at the cost of more memory and possibly
worst performance in ADDING elements (so you should also
specify the number of elements you wish to add).

Richard
 
Back
Top