bsearch-insert-pos.h revision 810bf6e564ebef9655fc0ca3b5273fbb6022c098
810bf6e564ebef9655fc0ca3b5273fbb6022c098Timo Sirainen/* Binary search template */
810bf6e564ebef9655fc0ca3b5273fbb6022c098Timo Sirainen#define BINARY_NUMBER_SEARCH(data, count, value, idx_r) \
9f5f6bdc3fd1304720b5d541bc31eb21417af6cbTimo Sirainen/* If key is found, returns TRUE and sets idx_r to the position where the key
9f5f6bdc3fd1304720b5d541bc31eb21417af6cbTimo Sirainen was found. If key isn't found, returns FALSE and sets idx_r to the position
9f5f6bdc3fd1304720b5d541bc31eb21417af6cbTimo Sirainen where the key should be inserted. */
9f5f6bdc3fd1304720b5d541bc31eb21417af6cbTimo Sirainenbool bsearch_insert_pos(const void *key, const void *base, unsigned int nmemb,
9f5f6bdc3fd1304720b5d541bc31eb21417af6cbTimo Sirainen size_t size, int (*cmp)(const void *, const void *),
9f5f6bdc3fd1304720b5d541bc31eb21417af6cbTimo Sirainen unsigned int *idx_r);