templates/linear_key_value_store/store_int_int.c
static void kv_store_int_int_search(struct kv_store_int_int *store, int key, ptrdiff_t *lower, ptrdiff_t *upper)
{
	ptrdiff_t low = -1;
	ptrdiff_t high = store->size;
	ptrdiff_t middle = (low + high) / 2;
	while (middle > low && middle < high) {
		int cmp = store->compar(key, store->data[middle].key);
		if (cmp > 0) {
			low = middle;
		} else if (cmp < 0) {
			high = middle;
		} else {
			low = middle;
			high = middle;
			break;
		}
		middle = (low + high) / 2;
	}

	*lower = low;
	*upper = high;

	return;
}
/* The key is searched in store. lower and upper are the return values. The key woth index lower is
 * less than or equal to key. The key with index upper is greater than or equal to key.  lower is at
 * most upper. lower can be -1 which means that key is below the first element in the store.  upper
 * can be size which means that the key is larger than all keys in the store. The compar function is
 * used for comparison. If upper == lower, the key is present in the store.
 */
The key is searched in store. lower and upper are the return values. The key woth index lower is
less than or equal to key. The key with index upper is greater than or equal to key.  lower is at
most upper. lower can be -1 which means that key is below the first element in the store.  upper
can be size which means that the key is larger than all keys in the store. The compar function is
used for comparison. If upper == lower, the key is present in the store.
The key is searched in store . lower and upper are the return values . The key woth index lower is less than or equal to key . The key with index upper is greater than or equal to key . lower is at most upper . lower can be - 1 which means that key is below the first element in the store . upper can be size which means that the key is larger than all keys in the store . The compar function is used for comparison . If upper == lower the key is present in the store .
static void kv_store_int_int_search(struct kv_store_int_int *store, int key, ptrdiff_t *lower, ptrdiff_t *upper)
{
	ptrdiff_t low = -1;
	ptrdiff_t high = store->size;
	ptrdiff_t middle = (low + high) / 2;
	while (middle > low && middle < high) {
		int cmp = store->compar(key, store->data[middle].key);
		if (cmp > 0) {
			low = middle;
		} else if (cmp < 0) {
			high = middle;
		} else {
			low = middle;
			high = middle;
			break;
		}
		middle = (low + high) / 2;
	}
	*lower = low;
	*upper = high;
	return;
}
static void kv_store_int_int_search ( struct kv_store_int_int * store , int key , ptrdiff_t * lower , ptrdiff_t * upper ) { ptrdiff_t low = -1 ; ptrdiff_t high = store -> size ; ptrdiff_t middle = ( low + high ) / 2 ; while ( middle > low && middle < high ) { int cmp = store -> compar ( key , store -> data [ middle ] . key ) ; if ( cmp > 0 ) { low = middle ; } else if ( cmp < 0 ) { high = middle ; } else { low = middle ; high = middle ; break ; } middle = ( low + high ) / 2 ; } * lower = low ; * upper = high ; return ; }
The key is searched in store.
The key is searched in store .