Brian Silverman | 598d029 | 2018-08-04 23:56:47 -0700 | [diff] [blame^] | 1 | [/ |
| 2 | Copyright 2010 Neil Groves |
| 3 | Distributed under the Boost Software License, Version 1.0. |
| 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | /] |
| 6 | [section:adjacent_find adjacent_find] |
| 7 | |
| 8 | [heading Prototype] |
| 9 | |
| 10 | `` |
| 11 | template<class ForwardRange> |
| 12 | typename range_iterator<ForwardRange>::type |
| 13 | adjacent_find(ForwardRange& rng); |
| 14 | |
| 15 | template<class ForwardRange> |
| 16 | typename range_iterator<const ForwardRange>::type |
| 17 | adjacent_find(const ForwardRange& rng); |
| 18 | |
| 19 | template<class ForwardRange, class BinaryPredicate> |
| 20 | typename range_iterator<ForwardRange>::type |
| 21 | adjacent_find(ForwardRange& rng, BinaryPred pred); |
| 22 | |
| 23 | template<class ForwardRange, class BinaryPredicate> |
| 24 | typename range_iterator<const ForwardRange>::type |
| 25 | adjacent_find(const ForwardRange& rng, BinaryPred pred); |
| 26 | |
| 27 | template<range_return_value_re, class ForwardRange> |
| 28 | typename range_return<ForwardRange, re>::type |
| 29 | adjacent_find(ForwardRange& rng); |
| 30 | |
| 31 | template<range_return_value_re, class ForwardRange> |
| 32 | typename range_return<const ForwardRange, re>::type |
| 33 | adjacent_find(const ForwardRange& rng); |
| 34 | |
| 35 | template< |
| 36 | range_return_value re, |
| 37 | class ForwardRange, |
| 38 | class BinaryPredicate |
| 39 | > |
| 40 | typename range_return<ForwardRange, re>::type |
| 41 | adjacent_find(ForwardRange& rng, BinaryPredicate pred); |
| 42 | |
| 43 | template< |
| 44 | range_return_value re, |
| 45 | class ForwardRange, |
| 46 | class BinaryPredicate |
| 47 | > |
| 48 | typename range_return<const ForwardRange, re>::type |
| 49 | adjacent_find(const ForwardRange& rng, BinaryPredicate pred); |
| 50 | `` |
| 51 | |
| 52 | [heading Description] |
| 53 | |
| 54 | [*Non-predicate versions:] |
| 55 | |
| 56 | `adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `x == y` |
| 57 | |
| 58 | [*Predicate versions:] |
| 59 | |
| 60 | `adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `pred(x,y)` is `true`. |
| 61 | |
| 62 | [heading Definition] |
| 63 | |
| 64 | Defined in the header file `boost/range/algorithm/adjacent_find.hpp` |
| 65 | |
| 66 | [heading Requirements] |
| 67 | |
| 68 | [*For the non-predicate versions of adjacent_find:] |
| 69 | |
| 70 | * `ForwardRange` is a model of the __forward_range__ Concept. |
| 71 | * `ForwardRange`'s value type is a model of the `EqualityComparableConcept`. |
| 72 | |
| 73 | [*For the predicate versions of adjacent_find:] |
| 74 | |
| 75 | * `ForwardRange` is a model of the __forward_range__ Concept. |
| 76 | * `BinaryPredicate` is a model of the `BinaryPredicateConcept`. |
| 77 | * `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type. |
| 78 | |
| 79 | [heading Complexity] |
| 80 | |
| 81 | Linear. If `empty(rng)` then no comparisons are performed; otherwise, at most `distance(rng) - 1` comparisons. |
| 82 | |
| 83 | [endsect] |
| 84 | |
| 85 | |