53 #ifndef ACE_COMMON_BINARY_SEARCH_H
54 #define ACE_COMMON_BINARY_SEARCH_H
58 namespace ace_common {
103 template<
typename X,
typename K>
109 if (diff == 0)
break;
111 size_t c = a + diff / 2;
113 if (current == x)
return c;
147 [&list](
size_t i) {
return list[i]; } );
size_t binarySearchByKey(size_t size, const X &x, K &&key)
Perform a binary search for element 'x' on an abstract list of records which are sorted by the 'key'.
size_t binarySearch(const X list[], size_t size, const X &x)
Simplified version of binarySearchByKey() where the elements of the array and the searched element ar...