HashSet vs. List performance
- by Michael Damatov
It's clear that a search performance of the generic HashSet<T> class is higher than of the generic List<T> class. Just compare the hash-based key with the linear approach in the List<T> class.
However calculating a hash key may itself take some CPU cycles, so for a small amount of items the linear search can be a real alternative to the HashSet<T>.
My question: where is the break-even?
To simplify the scenario (and to be fair) let's assume that the List<T> class uses the element's Equals() method to identify an item.