| Home | Libraries | People | FAQ | More

##### adjacent_find

###### Prototype

    template<class ForwardRange>
    typename range_iterator<ForwardRange>::type
    adjacent_find(ForwardRange& rng);

    template<class ForwardRange>
    typename range_iterator<const ForwardRange>::type
    adjacent_find(const ForwardRange& rng);

    template<class ForwardRange, class BinaryPredicate>
    typename range_iterator<ForwardRange>::type
    adjacent_find(ForwardRange& rng, BinaryPred pred);

    template<class ForwardRange, class BinaryPredicate>
    typename range_iterator<const ForwardRange>::type
    adjacent_find(const ForwardRange& rng, BinaryPred pred);

    template<range_return_value_re, class ForwardRange>
    typename range_return<ForwardRange, re>::type
    adjacent_find(ForwardRange& rng);

    template<range_return_value_re, class ForwardRange>
    typename range_return<const ForwardRange, re>::type
    adjacent_find(const ForwardRange& rng);

    template<
        range_return_value re,
        class ForwardRange,
        class BinaryPredicate
        >
    typename range_return<ForwardRange, re>::type
    adjacent_find(ForwardRange& rng, BinaryPredicate pred);

    template<
        range_return_value re,
        class ForwardRange,
        class BinaryPredicate
        >
    typename range_return<const ForwardRange, re>::type
    adjacent_find(const ForwardRange& rng, BinaryPredicate pred);

###### Description

Non-predicate versions:

`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `x == y`

Predicate versions:

`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `pred(x,y)` is `true`.

###### Definition

Defined in the header file `boost/range/algorithm/adjacent_find.hpp`

###### Requirements

For the non-predicate versions of adjacent_find:

- `ForwardRange` is a model of the Forward Range Concept.
- `ForwardRange`'s value type is a model of the `EqualityComparableConcept`.

For the predicate versions of adjacent_find:

- `ForwardRange` is a model of the Forward Range Concept.
- `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
- `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type.

###### Complexity

Linear. If `empty(rng)` then no comparisons are performed; otherwise, at most `distance(rng) - 1` comparisons.