]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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:lexicographical_compare lexicographical_compare] | |
7 | ||
8 | [heading Prototype] | |
9 | ||
10 | `` | |
11 | template< | |
12 | class SinglePassRange1, | |
13 | class SinglePassRange2 | |
14 | > | |
15 | bool lexicographical_compare(const SinglePassRange1& rng1, | |
16 | const SinglePassRange2& rng2); | |
17 | ||
18 | template< | |
19 | class SinglePassRange1, | |
20 | class SinglePassRange2, | |
21 | class BinaryPredicate | |
22 | > | |
23 | bool lexicographical_compare(const SinglePassRange1& rng1, | |
24 | const SinglePassRange2& rng2, | |
25 | BinaryPredicate pred); | |
26 | `` | |
27 | ||
28 | [heading Description] | |
29 | ||
30 | `lexicographical_compare` compares element by element `rng1` against `rng2`. If the element from `rng1` is less than the element from `rng2` then `true` is returned. If the end of `rng1` without reaching the end of `rng2` this also causes the return value to be `true`. The return value is `false` in all other circumstances. The elements are compared using `operator<` in the non-predicate versions of `lexicographical_compare` and using `pred` in the predicate versions. | |
31 | ||
32 | [heading Definition] | |
33 | ||
34 | Defined in the header file `boost/range/algorithm/lexicographical_compare.hpp` | |
35 | ||
36 | [heading Requirements] | |
37 | ||
38 | [*For the non-predicate versions of lexicographical_compare:] | |
39 | ||
40 | * `SinglePassRange1` is a model of the __single_pass_range__ Concept. | |
41 | * `SinglePassRange2` is a model of the __single_pass_range__ Concept. | |
42 | * `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. | |
43 | * `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. | |
44 | * Let `x` be an object of `SinglePassRange1`'s value type. Let `y` be an object of `SinglePassRange2`'s value type. `x < y` must be valid. `y < x` must be valid. | |
45 | ||
46 | [*For the predicate versions of lexicographical_compare:] | |
47 | ||
48 | * `SinglePassRange1` is a model of the __single_pass_range__ Concept. | |
49 | * `SinglePassRange2` is a model of the __single_pass_range__ Concept. | |
50 | * `BinaryPredicate` is a model of the `BinaryPredicateConcept`. | |
51 | * `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. | |
52 | * `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. | |
53 | ||
54 | [heading Complexity] | |
55 | ||
56 | Linear. At most `2 * min(distance(rng1), distance(rng2))` comparisons. | |
57 | ||
58 | [endsect] | |
59 | ||
60 |