-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Add more Map.replace and .replaceAll methods (also for Multimap) #1600
Comments
As discussed in gitter, here is an add-on for the requirements. We would like to have the following function:
This way we could do stuff like:
A basic implementation could be something like that:
Thanks. |
Regarding the gitter discussion @benoitheinrich mentioned I came to the conclusion that we already have to more general method: <U extends V> Map<K, V> put(K key, U value, BiFunction<? super V, ? super U, ? extends V> merge); There could be the following variations: <U extends V> Map<K, V> put(K key, Supplier<U> value, BiFunction<? super V, ? super U, ? extends V> merge);
Map<K, V> put(K key, Supplier<? extends V> value, Function<? super V, ? extends V> merge);
Map<K, V> put(K key, V value, Function<? super V, ? extends V> merge); But adding these variations blows up the API. The existing |
@mduesterhoeft Great to have you onboard! This issue focuses only on the three additional methods mentioned in the first comment. (The other suggestions are in fact covered already by We have a Map hierarchy and a Multimap hierarchy. The impls of the existing replace* methods delegate to the internal Maps helpers. Many thanks :) |
@danieldietrich think this could be closed?! |
@mduesterhoeft That's right - thanks :) |
From the Java 8 API docs:
Offtopic: Interface and implementation popularity of Java mutable collections (presented on JavaOne 2016). It shows that Map is very popular.
The text was updated successfully, but these errors were encountered: