Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

 

History

History
18 lines (13 loc) · 765 Bytes

adjacent_difference.md

File metadata and controls

18 lines (13 loc) · 765 Bytes

adjacent_difference

Description : Finds the difference of an iterator with the one preceding it in the range from first to the second parameter. The values are stored in third parameter, which is returned. The first pointer of the returned iterator simply stores the value pointed by first parameter. A fourth parameter may contain the function which defines any custom operation on the pair.

Example:

    std::vector v {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};
	std::vector<size_t> r;
    std::adjacent_difference(v.begin(), v.end(), r.begin());
 
    for (auto n : r)
        std::cout << n << ' ';
 
    std::cout << '\n';

See Sample code Run Code