cpp/algorithm/exclusive scan

Computes an exclusive prefix sum operation using (or  for overloads ) for the range, using  as the initial value, and writes the results to the range beginning at. "exclusive" means that the i$th$ input element is not included in the i$th$ sum.

Formally, assigns through each iterator in  the value of the generalized noncommutative sum of  for every  in  over ,

where generalized noncommutative sum $GNSUM(op, a 1, ..., a N)$ is defined as follows:
 * if $N = 1$, $a 1$
 * if $N > 1$, $op(GNSUM(op, a 1, ..., a K), GNSUM(op, a M, ..., a N))$ for any K where $1 < K + 1 = M ≤ N$

In other words, the summation operations may be performed in arbitrary order, and the behavior is nondeterministic if is not associative.

Overloads are executed according to.

shall not invalidate iterators (including the end iterators) or subranges, nor modify elements in the ranges or. Otherwise, the behavior is undefined.

Return value
Iterator to the element past the last element written.

Complexity
$O(last - first)$ applications of the binary operation.