views:

225

answers:

3

Hi,

I'm looking for an implementation of IDictionary with better performance of the standard BCL one.

I'm looking for something with constant lookup time that performs really well with large number of elements (>10K) and is more GC friendly.

Ps: No, I'm not able to write one by myself :)

+7  A: 

The BCL dictionary already performs with amortized constant time and can easily handle 10K elements.

You say it should be "more GC friendly" - what's bothering you about the current version?

Are you adding elements to the dictionary frequently? If so, create it with a large initial capacity to avoid churn.

Jon Skeet
I came across an article on using a WeakReference for the key, value or both. It was a really interesting read. Maybe that is what he meant?
Jonathan C Dickinson
+2  A: 

I have not been able to benchmark the implementation, but an alternative - and more comprehensive - selection of generic collection classes is available from the University of Copenhagen here:

http://www.itu.dk/research/c5/

They offer a number of generic Dictionary implementations with differing backing solutions (Trees, HashTables etc.) It may be that one of these suits your needs. Performance was a prime factor in the development of this class library.

Of course, I'd recommend that you try the BCL generic Dictionary class first, as it will save you time and may suit your performance requirements just fine.

Dave R.
+2  A: 

I think you will be hard pressed to find a managed dictionary that is faster than the BCL one. I've attempted to write one, and I quickly found that is about as fast as it's going to get when you balance read\write performance.

Brian Rudolph