adjacent_find
adjacent_find
template<class FwdIt>
FwdIt adjacent_find(FwdIt first, FwdIt last);
template<class FwdIt, class Pred>
FwdIt adjacent_find(FwdIt first, FwdIt last, Pred pr);
The first template function determines the lowest N
in the range [0, last - first)
for which N + 1 != last - first
and the predicate *(first + N) == *(first + N + 1)
is true. It then returns first + N
. If no such value exists, the function returns last
. It evaluates the predicate exactly N + 1
times.
The second template function behaves the same, except that the predicate is pr(*(first + N), *(first + N + 1))
.
Sample programs: adjacent_find and adjacent_find (predicate version).