34inline Type*
binary_s(Type* array,
size_t size, Type key) {
35 int32_t lower_index(0), upper_index(size - 1), middle_index;
37 while (lower_index <= upper_index) {
38 middle_index = std::floor((lower_index + upper_index) / 2);
40 if (*(array + middle_index) < key)
41 lower_index = (middle_index + 1);
42 else if (*(array + middle_index) > key)
43 upper_index = (middle_index - 1);
45 return (array + middle_index);
60 uint32_t block_front(0), block_size = size == 0 ? 0 : 1;
61 while (block_front != block_size) {
62 if (*(array + block_size - 1) < key) {
63 block_front = block_size;
64 (block_size * 2 - 1 < size) ? (block_size *= 2) : block_size = size;
67 return binary_s<Type>(array + block_front, (block_size - block_front),
76 int* sorted_array =
new int[7]{7, 10, 15, 23, 70, 105, 203};
82 delete[] sorted_array;