SortedList<K,V> vs SortedDictionary<K,V> vs Dictionary<K,V> [duplicate]
I have a large collection of small objects, each has a unique string ident. I need to decide which class to use.
MSDN says about the first two
The two classes have similar object models, and both have O(log n) retrieval. Where the two classes differ is in memory use and spe开发者_高级运维ed of insertion and removal
Since I rarely insert, mostly just retrieve it seems both are good for me. What about the plain old Dictionary?
Plain-old dictionary is the best option if you're not interested in sorting (since it's O(1) retrieval). If you're not going to modify the list much you should use SortedList since it uses less memory.
精彩评论