-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Proposal: Add ImmutableHashSet<T>.Builder.TryGetValue #28160
Comments
Hello @GeorgeAlexandria thanks for your detailed proposal. This makes sense to me, would you mind structuring the issue description so that it is easier for our API Review folks to do the review? Here are the guidelines for API proposals: https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md Also here is an example on the format it should follow: https://github.com/dotnet/corefx/issues/35938 Thanks 😄 |
Hello @safern and thanks for you suggestions. Issue was updated and I'm hope that now it's more structured and easy to reviewed. |
Thanks @GeorgeAlexandria, I marked it as api-ready-for-review so that the API Review crew reviews this. |
Looks good as proposed. However, we should review the API surface of all immutable types and make sure that the API surface of the builder is logically equivalent. @GeorgeAlexandria / @safern would one of you be willing to do that? namespace System.Collections.Immutable
{
public partial class ImmutableHashSet<T>
{
public partial class Builder
{
public bool TryGetValue(T equalValue, out T actualValue);
}
}
public partial class ImmutableSortedSet<T>
{
public partial class Builder
{
public bool TryGetValue(T equalValue, out T actualValue);
}
}
} |
Did you mean to append proposed api or to review all immutable types and their builders api? |
I ran a diff between the API of each immutable collection and its builder & proposed some mostly appropriate fixes #822 |
Hi,
what's about adding to the
System.Collections.Immutable.ImmutableHashSet<T>.Builder
andSystem.Collections.Immutable.ImmutableSortedSet<T>.Builder
a methodbool TryGetValue(T equalValue, out T actualValue);
?Rationale and Usage
A main goals for it is that you may avoid redundant object allocations and performance issues in the cases when you have a custom
IEqualityComparer<T>
and, for example, try to remove a actual value if it equals existing value or something else:To avoid redundant object allocations in the example above, we can use a relevant builder, but we will search an items in the full set, when we have a less actual set. It may have a performance issues when th set is large and GetHashCode with Equals for items are expensive:
With proposed changes we can get items from the actual state of set:
Proposed API
Implementation
I guess that implementation of
Builder.TryGetValue
must be the same as theTryGetValue
from the corresponding immutable setAny suggestion would be grateful.
The text was updated successfully, but these errors were encountered: