Template Function ADS::closestValue

Function Documentation

template<class T>
std::size_t ADS::closestValue(const std::vector<T> &A, const T &x)

closestValue(): the first place of an item of the sorted A at the least distance from x, the smaller item on ties; O( log n )

Pre:

A is not empty and sorted

Post:

no item of A closer to x than A[ r ] (an audit)