Collector<T, A, R> constructor
const
Collector<T, A, R> ({
- required A supplier(),
- required void accumulator(
- A,
- T
- required A combiner(
- A,
- A
- required R finisher(
- A
Creates a new Collector with the specified functions.
A mutable reduction operation that accumulates input elements into a mutable result container, optionally transforming the accumulated result into a final representation after all input elements have been processed.
Reduction operations can be performed either sequentially or in parallel.
Examples of mutable reduction operations include: accumulating elements into a List; concatenating strings using a StringBuffer; computing summary information about elements such as sum, min, max, or average; computing "pivot table" summaries such as "maximum valued transaction by seller", etc.
Example
final collector = Collector<String, StringBuffer, String>(
supplier: () => StringBuffer(),
accumulator: (buffer, element) => buffer.write(element),
combiner: (buffer1, buffer2) => buffer1..write(buffer2.toString()),
finisher: (buffer) => buffer.toString(),
);
Implementation
const Collector({
required this.supplier,
required this.accumulator,
required this.combiner,
required this.finisher,
});