/usr/include/bobcat/binarysearch is in libbobcat-dev 3.19.01-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #ifndef INCLUDED_BOBCAT_BINARYSEARCH_
#define INCLUDED_BOBCAT_BINARYSEARCH_
namespace FBB
{
template <typename Iterator, typename Type>
Iterator binary_search(Iterator begin, Iterator end, Type const &value)
{
Iterator ret = end;
while (begin != end)
{
Iterator mid = begin + (end - begin >> 1);
if (value < *mid) // left half
end = mid;
else if (*mid < value) // right half
begin = mid + 1;
else
return mid;
}
return ret;
}
template <typename Iterator, typename Type, typename Comparator>
Iterator binary_search(Iterator begin, Iterator end, Type const &value,
Comparator comparator)
{
Iterator ret = end;
while (begin != end)
{
Iterator mid = begin + (end - begin >> 1);
if (comparator(value, *mid)) // left half
end = mid;
else if (comparator(*mid, value)) // right half
begin = mid + 1;
else
return mid;
}
return ret;
}
} // FBB
#endif
|