-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
When you need to convert a Map<K1, V1> into a Map<K2, V2>, there is an API for that - processAll, however it looks a bit inelegant:
Map<K1, V1> m1 = ...;
Map<K2, V2> m2 = m1.processAll(m1.keys, e1 -> makeE2(e1));
First, I need to explicitly pass m1.keys, secondly it always returns back a ListMap.
My suggestion is to add a couple of convenience methods:
-
Same as current `processAll, but without the keys, operating on all keys:
<Result> Map!<Key, Result> processAll(function Result(Entry) compute) { return processAll(keys, compute); } -
Same as current
processAll, but taking either the resulting map or a builder of the resulting map (similar to collectors/aggregators in Collection.x) to allow the result to be of the specific flavor (e.g. HashMap). Alternatively, we could simply extend the existingprocessAll` method like this:<Result> Map!<Key, Result> processAll(Iterable<Key> keys, function Result(Entry) compute, Map!<Key, Result>? result = Null)
Metadata
Metadata
Assignees
Labels
No labels