Added in version 36.1

Gatherers

public final class Gatherers
extends Object

java.lang.Object
   ↳ java.util.stream.Gatherers


Implementations of Gatherer that provide useful intermediate operations, such as windowing functions, folding functions, transforming elements concurrently, etc.

Summary

Public methods

static <T, R> Gatherer<T, ?, R> fold(Supplier<R> initial, BiFunction<? super R, ? super T, ? extends R> folder)

Returns a Gatherer that performs an ordered, reduction-like, transformation for scenarios where no combiner-function can be implemented, or for reductions which are intrinsically order-dependent.

static <T, R> Gatherer<T, ?, R> scan(Supplier<R> initial, BiFunction<? super R, ? super T, ? extends R> scanner)

Returns a Gatherer that performs a Prefix Scan -- an incremental accumulation -- using the provided functions.

static <TR> Gatherer<TR, ?, List<TR>> windowFixed(int windowSize)

Returns a Gatherer that gathers elements into windows -- encounter-ordered groups of elements -- of a fixed size.

static <TR> Gatherer<TR, ?, List<TR>> windowSliding(int windowSize)

Returns a Gatherer that gathers elements into windows -- encounter-ordered groups of elements -- of a given size, where each subsequent window includes all elements of the previous window except for the least recent, and adds the next element in the stream.

Inherited methods