-
Notifications
You must be signed in to change notification settings - Fork 11k
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
ImmutableMap.Builder should have remove method #3596
Comments
In general, we recommend mutating a mutable map type instead of trying to pretend a builder is a mutable map. So, use a |
Then one has to make a mutable copy of an existing map, even the original map is mutable, because we may not want the original map to be mutated. Map copy = new LinkedHashMap(map);
copy.remove("key1");
Map newMapWithoutKey1 = ImmutableMap.copyOf(copy); |
That seems fine to me. If you're super worried about performance, you can add the entries from the existing mutable map to the Or, alternatively, use a lazy |
Thanks. It is fine to me as well. If I'm supper worried about performance, I have to use |
That sounds approximately correct, yes. |
Without
Builder.remove()
method, it will be very inefficient to create a new immutable map from an existing immutable map removing a key:The text was updated successfully, but these errors were encountered: