Java Reference
In-Depth Information
consequence, there's no need to perform a transformation, so the finisher method just has to
return the identity function:
public Function<List<T>, List<T>> finisher() {
return Function.identity();
}
These first three methods are enough to execute a sequential reduction of the stream that, at
least from a logical point of view, could proceed as in figure 6.7 . The implementation details are
a bit more difficult in practice due to both the lazy nature of the stream, which could require a
pipeline of other intermediate operations to execute before the collect operation, and the
possibility, in theory, of performing the reduction in parallel.
Figure 6.7. Logical steps of the sequential reduction process
Merging two result containers: the combiner method
The combiner method, the last of the four methods that return a function used by the reduction
operation, defines how the accumulators resulting from the reduction of different subparts of
 
Search WWH ::




Custom Search