summaryrefslogtreecommitdiff
path: root/libs/range/doc/reference/algorithm/equal_range.qbk
blob: 2d6c342df8425e5087ed1e9f9fbb6f3872c707b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
[/
    Copyright 2010 Neil Groves
    Distributed under the Boost Software License, Version 1.0.
    (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
[section:equal_range equal_range]

[heading Prototype]

``
template<
    class ForwardRange,
    class Value
    >
std::pair<typename range_iterator<ForwardRange>::type,
          typename range_iterator<ForwardRange>::type>
equal_range(ForwardRange& rng, const Value& val);

template<
    class ForwardRange,
    class Value
    >
std::pair<typename range_iterator<const ForwardRange>::type,
          typename range_iterator<const ForwardRange>::type>
equal_range(const ForwardRange& rng, const Value& val);

template<
    class ForwardRange,
    class Value,
    class SortPredicate
    >
std::pair<typename range_iterator<ForwardRange>::type,
          typename range_iterator<ForwardRange>::type>
equal_range(ForwardRange& rng, const Value& val, SortPredicate pred);

template<
    class ForwardRange,
    class Value,
    class SortPredicate
    >
std::pair<typename range_iterator<const ForwardRange>::type,
          typename range_iterator<const ForwardRange>::type>
equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred);                      
 ``

[heading Description]

`equal_range` returns a range in the form of a pair of iterators where all of the elements are equal to `val`. If no values are found that are equal to `val`, then an empty range is returned, hence `result.first == result.second`. For the non-predicate versions of `equal_range`  the equality of elements is determined by `operator<`.
For the predicate versions of `equal_range` the equality of elements is determined by `pred`.

[heading Definition]

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

[heading Requirements]

[*For the non-predicate versions:]

* `ForwardRange` is a model of the __forward_range__ Concept.
* `Value` is a model of the `LessThanComparableConcept`.
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
* `ForwardRange`'s value type is the same type as `Value`.

[*For the predicate versions:]

* `ForwardRange` is a model of the __forward_range__ Concept.
* `SortPredicate` is a model of the `StrictWeakOrderingConcept`.
* `ForwardRange`'s value type is the same as `Value`.
* `ForwardRange`'s value type is convertible to both of `SortPredicate`'s argument types.

[heading Precondition:]

For the non-predicate versions: `rng` is ordered in ascending order according to `operator<`.

For the predicate versions: `rng` is ordered in ascending order according to `pred`.

[heading Complexity]

For random-access ranges, the complexity is `O(log N)`, otherwise the complexity is `O(N)`. 

[endsect]