mirror of
https://github.com/boostorg/range.git
synced 2025-07-29 12:27:42 +02:00
Boost.RangeEx merged into Boost.Range
[SVN r60897]
This commit is contained in:
55
doc/reference/algorithm/binary_search.qbk
Normal file
55
doc/reference/algorithm/binary_search.qbk
Normal file
@ -0,0 +1,55 @@
|
||||
[section:binary_search binary_search]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Value>
|
||||
bool binary_search(const ForwardRange& rng, const Value& val);
|
||||
|
||||
template<class ForwardRange, class Value, class BinaryPredicate>
|
||||
bool binary_search(const ForwardRange& rng, const Value& val, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`binary_search` returns `true` if and only if the value `val` exists in the range `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/binary_search.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of binary_search:]
|
||||
|
||||
* `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 of binary_search:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s argument type.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
`rng` is ordered in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
`rng` is ordered in ascending order according to the function object `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For non-random-access ranges, the complexity is `O(N)` where `N` is `distance(rng)`.
|
||||
|
||||
For random-access ranges, the complexity is `O(log N)` where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
Reference in New Issue
Block a user