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:equal equal] |
| 7 | |
| 8 | [heading Prototype] |
| 9 | |
| 10 | `` |
| 11 | template< |
| 12 | class SinglePassRange1, |
| 13 | class SinglePassRange2 |
| 14 | > |
| 15 | bool equal(const SinglePassRange1& rng1, |
| 16 | const SinglePassRange2& rng2); |
| 17 | |
| 18 | template< |
| 19 | class SinglePassRange1, |
| 20 | class SinglePassRange2, |
| 21 | class BinaryPredicate |
| 22 | > |
| 23 | bool equal(const SinglePassRange1& rng1, |
| 24 | const SinglePassRange2& rng2, |
| 25 | BinaryPredicate pred); |
| 26 | `` |
| 27 | |
| 28 | [heading Description] |
| 29 | |
| 30 | `equal` returns `true` if `distance(rng1)` is equal to the `distance(rng2)` and for each element `x` in `rng1`, the corresponding element `y` in `rng2` is equal. Otherwise `false` is returned. |
| 31 | |
| 32 | In this range version of `equal` it is perfectly acceptable to pass in two ranges of unequal lengths. |
| 33 | |
| 34 | Elements are considered equal in the non-predicate version if `operator==` returns `true`. Elements are considered equal in the predicate version if `pred(x,y)` is `true`. |
| 35 | |
| 36 | [heading Definition] |
| 37 | |
| 38 | Defined in the header file `boost/range/algorithm/equal.hpp` |
| 39 | |
| 40 | [heading Requirements] |
| 41 | |
| 42 | [*For the non-predicate versions:] |
| 43 | |
| 44 | * `SinglePassRange1` is a model of the __single_pass_range__ Concept. |
| 45 | * `SinglePassRange2` is a model of the __single_pass_range__ Concept. |
| 46 | * `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`. |
| 47 | * `SinglePassRange2`'s value type is a model of the `EqualityComparableConcept`. |
| 48 | * `SinglePassRange1`'s value type can be compared for equality with `SinglePassRange2`'s value type. |
| 49 | |
| 50 | [*For the predicate versions:] |
| 51 | |
| 52 | * `SinglePassRange1` is a model of the __single_pass_range__ Concept. |
| 53 | * `SinglePassRange2` is a model of the __single_pass_range__ Concept. |
| 54 | * `BinaryPredicate` is a model of the `BinaryPredicateConcept`. |
| 55 | * `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. |
| 56 | * `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. |
| 57 | |
| 58 | [heading Complexity] |
| 59 | |
| 60 | Linear. At most `min(distance(rng1), distance(rng2))` comparisons. |
| 61 | |
| 62 | [endsect] |
| 63 | |
| 64 | |