/* This header defines the function for binary search in a sorted array. */ #ifndef BINARY_SEARCH_H #define BINARY_SEARCH_H /* Constants. */ #define BINARY_SEARCH_COMPARISON_LARGER_THAN 1 #define BINARY_SEARCH_COMPARISON_EQUAL_TO 0 #define BINARY_SEARCH_COMPARISON_LESS_THAN -1 #define BINARY_SEARCH_INDEX_NOT_FOUND -1 /* Function definitions. */ int binary_search(void* array, void* value, int (*comparison_function)(const void*, const void*), const int length, size_t size); #endif /* BINARY_SEARCH_H */