static void Downsweep <T>(T[] input, T t0, Func <T, T, T> f, TreeResult <T> t, T[] output) { var leaf = t as Leaf <T>; if (leaf != null) { ScanLeftSequential(input, leaf.From, leaf.To, t0, f, output); } else if (t is Node <T> ) { var node = (Node <T>)t; var _ = Parallel( Task.Run(() => Downsweep(input, t0, f, node.Left, output)), Task.Run(() => Downsweep(input, f(t0, node.Left.Result), f, node.Right, output)) ); } }
public Node(TreeResult <T> left, T result, TreeResult <T> right) { Left = left; Right = right; Result = result; }