Why SortedSet<T>.GetViewBetween isn't O(log N)?
In .NET 4.0+, a class SortedSet<T> has a method called GetViewBetween(l, r) , which returns an interface view on a tree part containing all the values between the two specified. Given that SortedSet<T> is implemented as a red-black tree, I naturally expect it to run in O(log N) time. The similar method in C++ is std::set::lower_bound/upper_bound , in Java it's TreeSet.headSet/tailSet , and they are logarithmic. However, that is not true. The following code runs in 32 sec, whereas the equivalent O(log N) version of GetViewBetween would make this code run in 1-2 sec. var s = new SortedSet<int>()