Open AlexRadch opened 1 year ago
Tagging subscribers to this area: @dotnet/area-system-collections See info in area-owners.md if you want to be subscribed.
Author: | AlexRadch |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Collections` |
Milestone: | - |
Note that the immutable/frozen extension methods are defined on the collection types themselves rather than Linq. ToHashSet
/ToDictionary
/ToLookup
are exceptions as they serve as accelerator methods for common lookup patterns. ToSortedSet
/ToSortedDictionary
don't add much functionality-wise other than providing alternative set/dictionary implementations that are typically slower than their hashtable equivalents.
I don't see how these additions would be useful other than use cases specifically looking to construct the particular collection types. Similar to the immutable/frozen extensions, we might consider adding these to the collection types directly, but I'm not sure that it would be valuable for most users.
Background and motivation
All sets and dictionaries (HashSet, Dictionary, ILookup, ImmutableHashSet, ImmutableSortedSet, ImmutableDictionary, ImmutableSortedDictionary, FrozenSet, FrozenDictionary) have extension methods that convert enumerable to that set/dictionary except
SortedSet
andSortedDictionary
.I suggest adding ToSortedSet and ToSortedDictionary extension methods to the Enumerable class.
API Proposal
API Usage
The same as
ToHashSet
andToDictionary
.Alternative Designs
No response
Risks
No response