I was reading about C#'s ImmutableSortedDictionary
in System.Collections.Immutable
and thinking about how to apply it in my program. I quite like C++'s lower_bound
and upper_bound
(see here), and I was rather expecting to see something of the sort for range lookups. However, similar methods seem to be strangely absent from the documentation. Am I missing something? Or does MS truly provide a sorted dictionary without efficient access to the sorted ranges? That doesn't exactly seem like something one could do on an IEnumerable
of the keys as say an extension method, so I'm a bit puzzled I'm not seeing something provided directly by the collection.
It is irritating that the available built-in collections are not offering a full set of features (like the SortedDictionary
lacking a BinarySearch
method), forcing us to search for third-party solutions (like the C5 library).
In your case instead of an ImmutableSortedDictionary
you could probably use a ImmutableSortedSet
, embedding the values in the keys and using an appropriate comparer. At least the API of this class contains the properties Min
and Max
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With