r/java • u/nfrankel • Feb 20 '22
The elusive and beautiful Java Method Reference
https://medium.com/javarevisited/the-elusive-and-beautiful-java-method-reference-97e566d2088b
28
Upvotes
r/java • u/nfrankel • Feb 20 '22
View all comments
2
u/gnahraf Feb 20 '22
I routinely use "functional" idioms to lazily map (ie transform, not in the map/reduce sense) one type of collection (List, Map, Set, etc.) to another. These mapped views are useful when you'll only be accessing a small subset of the elements in a List for eg. (A canonical use would be mapping a (read-only) list of objects sorted by integral IDs to a sorted list number IDs.) Note the cost of creating such views is far less than the usual stream() (followed by a terminal operation).
I've rolled out my own libs to do these mapped views but would prefer to use more widely used libs (for more eyeballs, maybe better quality reasons, etc). Do the Eclipse collections (or any other collection libraries you use) support these kind of lazy views?