]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/doc/reference/algorithm/binary_search.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / range / doc / reference / algorithm / binary_search.qbk
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:binary_search binary_search]
7
8 [heading Prototype]
9
10 ``
11 template<class ForwardRange, class Value>
12 bool binary_search(const ForwardRange& rng, const Value& val);
13
14 template<class ForwardRange, class Value, class BinaryPredicate>
15 bool binary_search(const ForwardRange& rng, const Value& val, BinaryPredicate pred);
16 ``
17
18 [heading Description]
19
20 `binary_search` returns `true` if and only if the value `val` exists in the range `rng`.
21
22 [heading Definition]
23
24 Defined in the header file `boost/range/algorithm/binary_search.hpp`
25
26 [heading Requirements]
27
28 [*For the non-predicate versions of binary_search:]
29
30 * `ForwardRange` is a model of the __forward_range__ Concept.
31 * `Value` is a model of the `LessThanComparableConcept`.
32 * The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
33 * `ForwardRange`'s value type is the same type as `Value`.
34
35 [*For the predicate versions of binary_search:]
36
37 * `ForwardRange` is a model of the __forward_range__ Concept.
38 * `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
39 * `ForwardRange`'s value type is the same type as `Value`.
40 * `ForwardRange`'s value type is convertible to `BinaryPredicate`'s argument type.
41
42 [heading Precondition:]
43
44 [*For the non-predicate version:]
45
46 `rng` is ordered in ascending order according to `operator<`.
47
48 [*For the predicate version:]
49
50 `rng` is ordered in ascending order according to the function object `pred`.
51
52 [heading Complexity]
53
54 For non-random-access ranges, the complexity is `O(N)` where `N` is `distance(rng)`.
55
56 For random-access ranges, the complexity is `O(log N)` where `N` is `distance(rng)`.
57
58 [endsect]
59
60