Skip to content

distinctBy but with last element #2712

@ckosmowski

Description

@ckosmowski

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" ?

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions