forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ICollection<T> on ToLookup (dotnet#98895)
LINQ's ToLookup returns an ILookup. The object we return today on some platforms implements `IIListProvider`. Instead, we can just have the returned object always implement `ICollection<T>`. The provided CopyTo then enables the default ToArray/ToList implementations to still be efficient. Implementing ICollection enables other uses to also take advantage of implementations like CopyTo and Count. As `Lookup<TKey, TElement>` is public, this doesn't implement the interface on that type and instead derives a sealed internal type that provides the interface implementation (which is minimal). If we want to augment the public API, we could do so subsequently and delete the internal derived type.
- Loading branch information
1 parent
8ccb71e
commit 05f9a34
Showing
4 changed files
with
100 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters