This post originated from an RSS feed registered with .NET Buzz
by Richard Jonas.
Original Post: C# collection classes performance
Feed Title: Richard Jonas
Feed URL: http://feeds.feedburner.com/blogspot/ouNA
Feed Description: Richard Jonas's blog about .NET, web development and agile methodologies.
I was looking for a table summarizing how different C# generic and non-generic collection classes performed, relative to one another, thought there would be hundreds available, but could not find one. So here one is for my future reference, and for anyone else who reads this.
O(1) = constant time O(log n) = time proportional to the log of the number of elements in the collection O(n) = time proportional to the number of elements in the collection
Some collections are better for smaller collections, but don't scale to larger ones. The List, LinkedList, SortedList, Queue and Stack classes are better for smaller collections than the Dictionary, Hashtable and SortedDictionary classes.