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
|
hi(lower_bound)
itemization(
it() Header file: tt(<algorithm>)
it() Function prototypes:
itemization(
itt(ForwardIterator lower_bound(ForwardIterator first,
ForwardIterator last, const Type &value);)
itt(ForwardIterator lower_bound(ForwardIterator first,
ForwardIterator last, const Type &value, BinaryPredicate
pred);)
)
it() Description:
itemization(
it() The first prototype: the sorted elements (using ascending
sort) reached from the iterator range rangett(first, last) are searched for
the first element that is not less than (i.e., greater than or equal to)
tt(value). The returned iterator marks the location in the sequence where
tt(value) can be inserted without breaking the sorted order of the
elements. The tt(operator<) of the data type to which the iterators point is
used. If no such element is found, tt(last) is returned.
it() The second prototype: the elements reached from the iterator
range rangett(first, last) must have been sorted using the tt(comp) function
(-object). Each element in the range is compared to tt(value) using the
tt(comp) function, receiving an element from the iterator range as its first
argument and tt(type) as its second argument. An iterator to the first element
for which the binary predicate tt(comp), applied to the elements of the range
and tt(value), returns tt(false) is returned. If no such element is found,
tt(last) is returned.
As illustrated by the following example, the function object
function's first parameter refers to an element in the iterator range, while
the function object's second parameter refers to tt(value).
)
it() Example:
verbinclude(-a examples/lowerbound.cc)
)
The tt(binary_search) generic algorithm (cf. section ref(BINSRCH))can be used
to determine whether or not tt(value) is present in the iterator range. The
tt(upper_bound) algorithm can be used to find the last element of a series of
values equal to tt(value). The tt(upper_bound) section (ref(UPPERBOUND)) also
contains an extensive example illustrating the use of tt(lower_bound) and as
tt(upper_bound).
|