stl:algorithm:adjacent_difference

C++ Reference

adjacent_difference

Syntax:

    #include <numeric>
    iterator adjacent_difference( iterator start, iterator end, iterator result );
    iterator adjacent_difference( iterator start, iterator end, iterator result, BinaryFunction f );

The adjacent_difference() function calculates the differences between adjacent elements in the range [start,end) and stores the result starting at result. If a binary function f is given, it is used instead of the - operator to compute the differences. adjacent_difference() runs in linear time.

Related Topics: accumulate, count, inner_product, partial_sum