I have heard that the .NET System.Collections.Immutable
collections are implemented as balanced binary trees in order to satisfy their immutability constraints, even collections which traditionally model hash tables like Dictionary
, by using the integral value of GetHashCode
as a sort key.
If I have a type for which it is cheap to generate a hash code, and for which is cheap to compare (e.g. string
or int
), and I don't care about the sorted-ness of my collection, would it make sense to prefer ImmutableSortedDictionary
because the underlying data structure is sorted anyway?