Java Reference
In-Depth Information
You can now use this new custom collector in place of the former one created with the
partitioningBy factory method in section 6.4 and obtain exactly the same result:
public Map<Boolean, List<Integer>>
partitionPrimesWithCustomCollector(int n) {
return IntStream.rangeClosed(2, n).boxed()
.collect(new PrimeNumbersCollector());
}
6.6.2. Comparing collectors' performances
The collector created with the partitioningBy factory method and the custom one you just
developed are functionally identical, but did you achieve your goal of improving the
performance of the partitioningBy collector with your custom one? Let's write a quick harness to
check this:
 
Search WWH ::




Custom Search