Collector<T, A, R> class
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(),
);
- Annotations
-
- @Generic(Collector)
Constructors
Properties
- accumulator → void Function(A, T)
-
A function that folds a value into a mutable result container.
final
- combiner → A Function(A, A)
-
A function that accepts two partial results and merges them.
final
- finisher → R Function(A)
-
A function that transforms the intermediate accumulation result into the
final result type.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- supplier → A Function()
-
A function that creates and returns a new mutable result container.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited