blob: 2d6c342df8425e5087ed1e9f9fbb6f3872c707b0 [file] [log] [blame]
Brian Silverman598d0292018-08-04 23:56:47 -07001[/
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_range equal_range]
7
8[heading Prototype]
9
10``
11template<
12 class ForwardRange,
13 class Value
14 >
15std::pair<typename range_iterator<ForwardRange>::type,
16 typename range_iterator<ForwardRange>::type>
17equal_range(ForwardRange& rng, const Value& val);
18
19template<
20 class ForwardRange,
21 class Value
22 >
23std::pair<typename range_iterator<const ForwardRange>::type,
24 typename range_iterator<const ForwardRange>::type>
25equal_range(const ForwardRange& rng, const Value& val);
26
27template<
28 class ForwardRange,
29 class Value,
30 class SortPredicate
31 >
32std::pair<typename range_iterator<ForwardRange>::type,
33 typename range_iterator<ForwardRange>::type>
34equal_range(ForwardRange& rng, const Value& val, SortPredicate pred);
35
36template<
37 class ForwardRange,
38 class Value,
39 class SortPredicate
40 >
41std::pair<typename range_iterator<const ForwardRange>::type,
42 typename range_iterator<const ForwardRange>::type>
43equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred);
44 ``
45
46[heading Description]
47
48`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<`.
49For the predicate versions of `equal_range` the equality of elements is determined by `pred`.
50
51[heading Definition]
52
53Defined in the header file `boost/range/algorithm/equal_range.hpp`
54
55[heading Requirements]
56
57[*For the non-predicate versions:]
58
59* `ForwardRange` is a model of the __forward_range__ Concept.
60* `Value` is a model of the `LessThanComparableConcept`.
61* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
62* `ForwardRange`'s value type is the same type as `Value`.
63
64[*For the predicate versions:]
65
66* `ForwardRange` is a model of the __forward_range__ Concept.
67* `SortPredicate` is a model of the `StrictWeakOrderingConcept`.
68* `ForwardRange`'s value type is the same as `Value`.
69* `ForwardRange`'s value type is convertible to both of `SortPredicate`'s argument types.
70
71[heading Precondition:]
72
73For the non-predicate versions: `rng` is ordered in ascending order according to `operator<`.
74
75For the predicate versions: `rng` is ordered in ascending order according to `pred`.
76
77[heading Complexity]
78
79For random-access ranges, the complexity is `O(log N)`, otherwise the complexity is `O(N)`.
80
81[endsect]
82
83