Function vector_bsearch_dec (o2scl)¶
-
template<class vec_t, class data_t>
size_t o2scl::vector_bsearch_dec(const data_t x0, const vec_t &x, size_t lo, size_t hi)¶ Binary search a part of an decreasing vector for
x0
.This function performs a binary search of between
x[lo]
andx[hi]
(inclusive). It returnslo
ifx0
>x[lo]
i
ifx[i]
>=x0
>x[i+1]
forlo
<=i
<hi
hi-1
ifx0
<=[hi-1]
The element at
x[hi]
is never referenced by this function. The parameterhi
can be either the index of the last element (e.g.n-1
for a vector of sizen
with starting index0
), or the index of one element (e.g.n
for a vector of sizen
and a starting index0
) for a depending on whether or not the user wants to allow the function to return the index of the last element.The operation of this function is undefined if the data is not strictly monotonic, i.e. if some of the data elements are equal.
This function will call the error handler if
lo
is greater thanhi
.