The fastest Contains() in .NET - Part 2
A follow-up to my recent post about The fastest Contains() in .NET.
John Merchant pointed out that there's more detail on the Microsoft Docs site for the Contains() method for each of these types, which includes the Big O notation.
eg.
Method | Order |
---|---|
List<T>Contains(T) | O(n) |
SortedSet<T>Contains(T) | O(log n) |
HashSet<T>Contains(T) | O(1) |
Sometimes it pays to read the documentation!
Categories: .NET