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 returnsloifx0>x[lo]iifx[i]>=x0>x[i+1]forlo<=i<hihi-1ifx0<=[hi-1]
The element at
x[hi]is never referenced by this function. The parameterhican be either the index of the last element (e.g.n-1for a vector of sizenwith starting index0), or the index of one element (e.g.nfor a vector of sizenand 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
lois greater thanhi.