We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I see that CapsuleCollectors.toMap is commented in the code. Is there any reason not to make it available?
CapsuleCollectors.toMap
That's how I reimplemented it:
public static <T, K, V> Collector<T, ?, io.usethesource.capsule.Map.Immutable<K, V>> toMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper ) { /** extract key/value from type {@code T} and insert into map */ final BiConsumer<io.usethesource.capsule.Map.Transient<K, V>, T> accumulator = (map, element) -> map.__put(keyMapper.apply(element), valueMapper.apply(element)); return new DefaultCollector<>( io.usethesource.capsule.Map.Transient::of, accumulator, (left, right) -> { left.__putAll(right); return left; }, io.usethesource.capsule.Map.Transient::freeze, CapsuleCollectors.UNORDERED ); }
Another one would be the same but using a function to merge values in case one already exists in the transient map.
Thanks!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I see that
CapsuleCollectors.toMap
is commented in the code. Is there any reason not to make it available?That's how I reimplemented it:
Another one would be the same but using a function to merge values in case one already exists in the transient map.
Thanks!
The text was updated successfully, but these errors were encountered: