apply clang-format
This commit is contained in:
@ -1288,7 +1288,7 @@ int utils::date2num(const std::string &date)
|
||||
int utils::binary_search(const double needle, const int n, const double *haystack)
|
||||
{
|
||||
int lo = 0;
|
||||
int hi = n-1;
|
||||
int hi = n - 1;
|
||||
|
||||
if (needle < haystack[lo]) return lo;
|
||||
if (needle >= haystack[hi]) return hi;
|
||||
@ -1296,11 +1296,13 @@ int utils::binary_search(const double needle, const int n, const double *haystac
|
||||
// insure haystack[lo] <= needle < haystack[hi] at every iteration
|
||||
// done when lo,hi are adjacent
|
||||
|
||||
int index = (lo+hi)/2;
|
||||
while (lo < hi-1) {
|
||||
if (needle < haystack[index]) hi = index;
|
||||
else if (needle >= haystack[index]) lo = index;
|
||||
index = (lo+hi)/2;
|
||||
int index = (lo + hi) / 2;
|
||||
while (lo < hi - 1) {
|
||||
if (needle < haystack[index])
|
||||
hi = index;
|
||||
else if (needle >= haystack[index])
|
||||
lo = index;
|
||||
index = (lo + hi) / 2;
|
||||
}
|
||||
|
||||
return index;
|
||||
|
||||
Reference in New Issue
Block a user