templates/linear_key_value_store/store_int_int.c
bool kv_store_int_int_put(struct kv_store_int_int *store, int key, int value)
{
	ptrdiff_t lower;
	ptrdiff_t upper;
	kv_store_int_int_search(store, key, &lower, &upper);

	if (lower == upper) {
		store->data[lower].value = value;
		return true;
	} else {
		if (store->size == store->capacity) {
			size_t new_capacity = 2 * store->capacity + 1;
			struct kv_tuple_int_int *new_data = realloc(store->data, new_capacity * sizeof(struct kv_tuple_int_int));
			if (new_data == NULL) return false;
			store->data = new_data;
			store->capacity = new_capacity;
		}
		if (upper < store->size) {
			memmove(store->data + (upper + 1), store->data + upper, (store->size - upper) * sizeof(struct kv_tuple_int_int));
		}
		store->data[upper].key = key;
		store->data[upper].value = value;
		store->size++;
		return false;
	}
	
}
/* The value is inserted for the key. If the key is present, the value replaces the present value.
 * The bool return value is true if the key was present and false if the key was absent. 
 */
The value is inserted for the key. If the key is present, the value replaces the present value.
The bool return value is true if the key was present and false if the key was absent.
The value is inserted for the key . If the key is present the value replaces the present value . The bool return value is true if the key was present and false if the key was absent .
bool kv_store_int_int_put(struct kv_store_int_int *store, int key, int value)
{
	ptrdiff_t lower;
	ptrdiff_t upper;
	kv_store_int_int_search(store, key, &lower, &upper);
	if (lower == upper) {
		store->data[lower].value = value;
		return true;
	} else {
		if (store->size == store->capacity) {
			size_t new_capacity = 2 * store->capacity + 1;
			struct kv_tuple_int_int *new_data = realloc(store->data, new_capacity * sizeof(struct kv_tuple_int_int));
			if (new_data == NULL) return false;
			store->data = new_data;
			store->capacity = new_capacity;
		}
		if (upper < store->size) {
			memmove(store->data + (upper + 1), store->data + upper, (store->size - upper) * sizeof(struct kv_tuple_int_int));
		}
		store->data[upper].key = key;
		store->data[upper].value = value;
		store->size++;
		return false;
	}
}
bool kv_store_int_int_put ( struct kv_store_int_int * store , int key , int value ) { ptrdiff_t lower ; ptrdiff_t upper ; kv_store_int_int_search ( store , key , & lower , & upper ) ; if ( lower == upper ) { store -> data [ lower ] . value = value ; return true ; } else { if ( store -> size == store -> capacity ) { size_t new_capacity = 2 * store -> capacity + 1 ; struct kv_tuple_int_int * new_data = realloc ( store -> data , new_capacity * sizeof ( struct kv_tuple_int_int ) ) ; if ( new_data == NULL ) return false ; store -> data = new_data ; store -> capacity = new_capacity ; } if ( upper < store -> size ) { memmove ( store -> data + ( upper + 1 ) , store -> data + upper , ( store -> size - upper ) * sizeof ( struct kv_tuple_int_int ) ) ; } store -> data [ upper ] . key = key ; store -> data [ upper ] . value = value ; store -> size ++ ; return false ; } }
The value is inserted for the key.
The value is inserted for the key .