Open JnRouvignac opened 11 years ago
Functions allow to easily build Comparators with https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html#comparing-java.util.function.Function-
Refactoring loops into collection pipelines: http://martinfowler.com/articles/refactoring-pipelines.html
See http://www.techempower.com/blog/2013/03/26/everything-about-java-8/ :
@FunctionalInterface
with lambdas, - automatically convert code to do it@FunctionalInterface
to single method interfacesCollection.removeIf()
is O(n) forArrayList
rather than O(n2)Collections.sort(list, comparator)
=>List.sort(Comparator)
Map.computeIfAbsent()
to simplifyMultiMap
usagejava.util.function
- can anything be done automatically here?java.util.stream
- can anything be done automatically here?java.time
- can anything be done automatically here?java.util.Optional
- can anything be done automatically here?Comparator
(ex:comparingInt()
),Objects::nonNull()
, etc.java.lang
,java.util
, and elsewhere - can anything be done automatically here?Also see https://blog.jetbrains.com/upsource/2016/08/03/what-to-look-for-in-java-8-code/