create_accumulator() - creates a new accumulator, such as Gee.Collection.
accumulate() - incorporates a new element into a accumulator.
combine() - combines two accumulators into one.
finish() - transforms the accumulator into a final result.
The methods must satisfy an identity and an associativity constraints. The identity constraint means that combining any
accumulator with an empty accumulator must produce an equivalent result. i.e. an accumulator a must be equivalent to
collector.accumulate(a, collector.create_accumulator())
The associativity constraint means that splitting the computation must produce an equivalent result. i.e.:
// the two computations below must be equivalent. // collector: a collector // g0, g1: elements
A a0 = collector.create_accumulator(); collector.accumulate(g0, a0); collector.accumulate(g1, a0); A r0 = collector.finish(a0);
A a1 = collector.create_accumulator(); collector.accumulate(g0, a1); A a2 = collector.create_accumulator(); collector.accumulate(g1, a2); A r1 = collector.finish( collector.combine(a1, a2) );
Collectors also have a property, features. it provides hints that
can be used to optimize the operation.