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. (Specifically, the element at start will be copied to result; and then the difference between the element at start + i and start + (i-1) will be stored at result + i.)
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