accumulate

Syntax:

    #include <numeric>
    TYPE accumulate( iterator start, iterator end, TYPE val );
    TYPE accumulate( iterator start, iterator end, TYPE val, BinaryFunction f );

The accumulate() function computes the sum of val and all of the elements in the range [start,end). If the binary function f if specified, it is used instead of the + operator to perform the summation. accumulate() runs in linear time.

Related Topics: adjacent_difference, count, inner_product, partial_sum