eclipse-collections
eclipse-collections copied to clipboard
Introduce MutableMapIterable.putIfAbsent taking a Function0
Add, on top of of Map.putIfAbsent(K, V), a new method MutableMapIterable.putIfAbsent(K, Function0<V>).
The use case is to both:
- not instantiate the value if not needed (as with
MutableMapIterable.getIfAbsentPut(K, Function0<V>)) - know if the value was actually added (as with
Map.putIfAbsent(K, V)when it returnsnull)
Ideally, I would like is to have the 3 behaviours:
- not instantiate the value if not needed (as with
MutableMapIterable.getIfAbsentPut(K, Function0<V>)) - have the newly added or the existing value returned (as with
MutableMapIterable.getIfAbsentPut(K, Function0<V>)) - know if the value was actually added (as with
Map.putIfAbsent(K, V)when it returnsnull)
But I don't see how it's possible to do so with one unique method :)
Hello @victornoel , May i be assigned this issue. Thanks!
@IamLRBA go ahead and submit a PR, there's no need to be assigned the issue first.