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

distinctBy but with last element #2712

Open
ckosmowski opened this issue Mar 3, 2022 · 0 comments
Open

distinctBy but with last element #2712

ckosmowski opened this issue Mar 3, 2022 · 0 comments

Comments

@ckosmowski
Copy link

I am currently evaluating vavr as a replacement for Java 8 Streams. While processing batches of events we always want to keep the last value unique by some key. The semantics would be the same as

.reverse()
.dicstinctBy(e -> e.getSomeKey())
.reverse()

i think.

But i do think that this comes with performance hits. To achieve this we are using a LinkedHashMap where we put elements one after the other with their generated keys and afterwards get the .values() again from that map which will now contain only the last elements of each key.

Would you consider adding "distinctByLast" or as we call it "keepLast" ?

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

No branches or pull requests

1 participant