accumulator

積分器です。 積分するサンプル量が大きい場合の使用に適しています。

Examples

1 scope(failure) {writefln("Unittest failure :%s(%s)", __FILE__, __LINE__); stdout.flush();}
2 scope(success) {writefln("Unittest success :%s(%s)", __FILE__, __LINE__); stdout.flush();}
3 
4 auto acc = accumulator!int(4);
5 static assert(isOutputStream!(typeof(acc), int));
6 
7 assert(acc.write([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).empty);
8 assert(equal(acc[], [0+1+2+3, 4+5+6+7]));
9 
10 acc.write([10, 11]);
11 assert(equal(acc[], [0+1+2+3, 4+5+6+7, 8+9+10+11]));

Meta