Skip to content

Implement MapIterable.collectKeysUnique(). #409

@motlin

Description

@motlin
<R> MapIterable<R, V> collectKeysUnique(Function2<? super K, ? super V, ? extends R> function);

or

<R> MapIterable<R, V> collectKeysUnique(Function<? super K, ? extends R> function);

Similar to the existing api:

<R> MapIterable<K, R> collectValues(Function2<? super K, ? super V, ? extends R> function);

collectKeys is trickier than collectValues because after transformation, the new keys can be equal to each other and collapse into a smaller map. I'm inclined to say that collectKeys should throw, similar to the behavior of groupByUniqueKey, when the function returns non-unique results. On the other hand, RichIterable.toMap() and MutableMap.collectKeysAndValues() already silently collapse duplicates and no one seems to complain.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions