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:search search] |
| 7 | |
| 8 | [heading Prototype] |
| 9 | |
| 10 | `` |
| 11 | template<class ForwardRange1, class ForwardRange2> |
| 12 | typename range_iterator<ForwardRange1>::type |
| 13 | search(ForwardRange1& rng1, const ForwardRange2& rng2); |
| 14 | |
| 15 | template<class ForwardRange1, class ForwardRange2> |
| 16 | typename range_iterator<const ForwardRange1>::type |
| 17 | search(const ForwardRange1& rng1, const ForwardRange2& rng2); |
| 18 | |
| 19 | template< |
| 20 | class ForwardRange1, |
| 21 | class ForwardRange2, |
| 22 | class BinaryPredicate |
| 23 | > |
| 24 | typename range_iterator<ForwardRange1>::type, |
| 25 | search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); |
| 26 | |
| 27 | template< |
| 28 | class ForwardRange1, |
| 29 | class ForwardRange2, |
| 30 | class BinaryPredicate |
| 31 | > |
| 32 | typename range_iterator<const ForwardRange1>::type |
| 33 | search(const ForwardRange1& rng1, ForwardRange2& rng2, BinaryPredicate pred); |
| 34 | |
| 35 | |
| 36 | template< |
| 37 | range_return_value re, |
| 38 | class ForwardRange1, |
| 39 | class ForwardRange2 |
| 40 | > |
| 41 | typename range_return<ForwardRange1, re>::type |
| 42 | search(ForwardRange1& rng1, const ForwardRange2& rng2); |
| 43 | |
| 44 | template< |
| 45 | range_return_value re, |
| 46 | class ForwardRange1, |
| 47 | class ForwardRange2 |
| 48 | > |
| 49 | typename range_return<const ForwardRange1, re>::type |
| 50 | search(const ForwardRange1& rng1, const ForwardRange2& rng2); |
| 51 | |
| 52 | template< |
| 53 | range_return_value re, |
| 54 | class ForwardRange1, |
| 55 | class ForwardRange2, |
| 56 | class BinaryPredicate |
| 57 | > |
| 58 | typename range_return<ForwardRange1, re>::type, |
| 59 | search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); |
| 60 | |
| 61 | template< |
| 62 | range_return_value re, |
| 63 | class ForwardRange1, |
| 64 | class ForwardRange2, |
| 65 | class BinaryPredicate |
| 66 | > |
| 67 | typename range_return<const ForwardRange1, re>::type |
| 68 | search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); |
| 69 | `` |
| 70 | |
| 71 | [heading Description] |
| 72 | |
| 73 | The versions of `search` that return an iterator, return an iterator to the start of the first subsequence in `rng1` that is equal to the subsequence `rng2`. The `end(rng1)` is returned if no such subsequence exists in `rng1`. |
| 74 | Equality is determined by `operator==` for non-predicate versions of `search`, and by satisfying `pred` in the predicate versions. |
| 75 | |
| 76 | The versions of `search` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. |
| 77 | |
| 78 | [heading Definition] |
| 79 | |
| 80 | Defined in the header file `boost/range/algorithm/search.hpp` |
| 81 | |
| 82 | [heading Requirements] |
| 83 | |
| 84 | [*For the non-predicate versions:] |
| 85 | |
| 86 | * `ForwardRange1` is a model of the __forward_range__ Concept. |
| 87 | * `ForwardRange2` is a model of the __forward_range__ Concept. |
| 88 | * `ForwardRange1`'s value type is a model of the `EqualityComparableConcept`. |
| 89 | * `ForwardRange2`'s value type is a model of the `EqualityComparableConcept`. |
| 90 | * `ForwardRange1`s value type can be compared for equality with `ForwardRange2`'s value type. |
| 91 | |
| 92 | [*For the predicate versions:] |
| 93 | |
| 94 | * `ForwardRange1` is a model of the __forward_range__ Concept. |
| 95 | * `ForwardRange2` is a model of the __forward_range__ Concept. |
| 96 | * `BinaryPredicate` is a model of the `BinaryPredicateConcept`. |
| 97 | * `ForwardRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. |
| 98 | * `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. |
| 99 | |
| 100 | [heading Complexity] |
| 101 | |
| 102 | Average complexity is Linear. Worst-case complexity is quadratic. |
| 103 | |
| 104 | [endsect] |
| 105 | |
| 106 | |