Skip to content
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

FluentIterable.index equivalent #3119

Open
perceptron8 opened this issue Apr 18, 2018 · 2 comments
Open

FluentIterable.index equivalent #3119

perceptron8 opened this issue Apr 18, 2018 · 2 comments
Assignees

Comments

@perceptron8
Copy link
Contributor

http://google.github.io/guava/releases/24.1-jre/api/docs/com/google/common/collect/FluentIterable.html#index-com.google.common.base.Function-

Stream equivalent: stream.collect(Collectors.groupingBy(keyFunction)) behaves similarly, but returns a mutable Map<K, List<E>> instead, and may not preserve the order of entries).

Since 21.0, stream.collect(ImmutableListMultimap.toImmutableListMultimap(keyFunction, v -> v)) may be used.

@lowasser
Copy link
Contributor

It's not clear to me what this is asking for -- just a shortcut that doesn't require the v -> v?

@perceptron8
Copy link
Contributor Author

It seems to me that it was rather about updating javadoc. The note about stream equivalent appeared in 19.0. Since 21.0, instead of stream.collect(Collectors.groupingBy(keyFunction)) you can use stream.collect(ImmutableListMultimap.toImmutableListMultimap(keyFunction, v -> v)), which is even "more equivalent", as it preserves the order of entries and gives you ImmutableListMultimap<K, E>, not mutable Map<K, List<E>>.

Shortcut that doesn't require v -> v would be handy, but I don't insist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants