diff --git a/examples/dict.c b/examples/dict.c index 1e548a4..c4bebbb 100644 --- a/examples/dict.c +++ b/examples/dict.c @@ -4,7 +4,7 @@ #include #include #include -#include "../include/extra/dict.h" +#include "../include/dict.h" typedef vtype_dict dict_t; @@ -40,20 +40,25 @@ int main(int argc, char** argv) { dict_t dict; vtype_float fl = 0.0; + int a; + vtype_float b; dict_init(&dict); - for (size_t i = 0; i < 28; ++i) { + for (vtype_int32 i = 0; i < 28; ++i) { if (i%2) { - dict_update(&dict, (vtype_float)fl, (vtype_int32)i); + dict_update(&dict, fl, i); } else { - dict_update(&dict, (vtype_int32)i, (vtype_float)fl); + dict_update(&dict, i, fl); } fl += 0.05; } - dict_get(&dict, 14, "Get value:", print_value); - dict_pop(&dict, 0.25, "Pop value:", print_value); + a = 13; + b = 0.25; + + dict_get(&dict, a, "Get value:", print_value); + dict_pop(&dict, b, "Pop value:", print_value); dict_foreach(&dict, "Foreach loop:", print_value); diff --git a/include/dict.h b/include/dict.h index d6f9963..c5a827b 100644 --- a/include/dict.h +++ b/include/dict.h @@ -7,460 +7,33 @@ #ifndef LIBCDSB_DICT_H #define LIBCDSB_DICT_H -/*#####################################################################################################################*/ - typedef int (*dict_access_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data); +/*#####################################################################################################################*/ + extern void dict_init(vtype_dict* x) Nonnull__(1); -#define dict_pop(x, key, data, callback) _LIBCDSB_Generic (libcdsb_dict, get_by, key)(x, key, data, callback, 1) -#define dict_get(x, key, data, callback) _LIBCDSB_Generic (libcdsb_dict, get_by, key)(x, key, data, callback, 0) -#define dict_update(x, key, value) _LIBCDSB_Generic2(libcdsb_dict, update, key, value)(x, key, value) -#define dict_remove(x, key) dict_pop(x, key, 0, 0) +/*#####################################################################################################################*/ -#define in_dict(x, key) (dict_get(&x, key, 0, 0) == 0) +#define dict_pop(x, key, data, callback) libcdsb_dict_find (x, _LIBCDSB_value_pointer(key), _LIBCDSB_vtypeof(key), data, callback, 1) +#define dict_get(x, key, data, callback) libcdsb_dict_find (x, _LIBCDSB_value_pointer(key), _LIBCDSB_vtypeof(key), data, callback, 0) +#define dict_update(x, key, value) libcdsb_dict_update (x, _LIBCDSB_value_pointer(key), _LIBCDSB_vtypeof(key), _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)) +#define dict_inject(x, key, value) libcdsb_dict_inject (x, _LIBCDSB_value_pointer(key), _LIBCDSB_vtypeof(key), _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)) +#define dict_inject_key(x, key, value) libcdsb_dict_inject_key (x, _LIBCDSB_value_pointer(key), _LIBCDSB_vtypeof(key), _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)) +#define dict_inject_value(x, key, value) libcdsb_dict_inject_value(x, _LIBCDSB_value_pointer(key), _LIBCDSB_vtypeof(key), _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)) +#define dict_foreach(x, data, callback) libcdsb_dict_foreach (x, data, callback, 0) +#define dict_remove(x, key) dict_pop (x, key, 0, 0) + +#define in_dict(x, key) (dict_get(&x, key, 0, 0) == 0) /*#####################################################################################################################*/ -extern int libcdsb_dict_get_by_pointer(vtype_dict* x, const void* key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_cstring(vtype_dict* x, const char* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); -extern int libcdsb_dict_get_by_string (vtype_dict* x, const vtype_string* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); -extern int libcdsb_dict_get_by_array (vtype_dict* x, const vtype_array* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); -extern int libcdsb_dict_get_by_list (vtype_dict* x, const vtype_list* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); -extern int libcdsb_dict_get_by_map (vtype_dict* x, const vtype_map* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); -extern int libcdsb_dict_get_by_vset (vtype_dict* x, const vtype_set* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); -extern int libcdsb_dict_get_by_dict (vtype_dict* x, const vtype_dict* key, void* data, dict_access_callback, bool cut) Nonnull__(1,2); -extern int libcdsb_dict_get_by_boolean(vtype_dict* x, vtype_bool key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_int8 (vtype_dict* x, vtype_int8 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_int16 (vtype_dict* x, vtype_int16 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_int32 (vtype_dict* x, vtype_int32 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_int64 (vtype_dict* x, vtype_int64 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_uint8 (vtype_dict* x, vtype_uint8 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_uint16 (vtype_dict* x, vtype_uint16 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_uint32 (vtype_dict* x, vtype_uint32 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_uint64 (vtype_dict* x, vtype_uint64 key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_float (vtype_dict* x, vtype_float key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_double (vtype_dict* x, vtype_double key, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_get_by_ldouble(vtype_dict* x, vtype_ldouble key, void* data, dict_access_callback, bool cut) Nonnull__(1); - -extern bool libcdsb_dict_update_pointer_pointer(vtype_dict* x, const void* key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_cstring(vtype_dict* x, const void* key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_pointer_string (vtype_dict* x, const void* key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_pointer_array (vtype_dict* x, const void* key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_pointer_list (vtype_dict* x, const void* key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_pointer_map (vtype_dict* x, const void* key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_pointer_vset (vtype_dict* x, const void* key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_pointer_dict (vtype_dict* x, const void* key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_pointer_boolean(vtype_dict* x, const void* key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_int8 (vtype_dict* x, const void* key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_int16 (vtype_dict* x, const void* key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_int32 (vtype_dict* x, const void* key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_int64 (vtype_dict* x, const void* key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_uint8 (vtype_dict* x, const void* key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_uint16 (vtype_dict* x, const void* key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_uint32 (vtype_dict* x, const void* key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_uint64 (vtype_dict* x, const void* key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_float (vtype_dict* x, const void* key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_double (vtype_dict* x, const void* key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_pointer_ldouble(vtype_dict* x, const void* key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_cstring_pointer(vtype_dict* x, const char* key, const void* value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_cstring(vtype_dict* x, const char* key, const char* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_cstring_string (vtype_dict* x, const char* key, const vtype_string* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_cstring_array (vtype_dict* x, const char* key, const vtype_array* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_cstring_list (vtype_dict* x, const char* key, const vtype_list* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_cstring_map (vtype_dict* x, const char* key, const vtype_map* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_cstring_vset (vtype_dict* x, const char* key, const vtype_set* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_cstring_dict (vtype_dict* x, const char* key, const vtype_dict* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_cstring_boolean(vtype_dict* x, const char* key, vtype_bool value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_int8 (vtype_dict* x, const char* key, vtype_int8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_int16 (vtype_dict* x, const char* key, vtype_int16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_int32 (vtype_dict* x, const char* key, vtype_int32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_int64 (vtype_dict* x, const char* key, vtype_int64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_uint8 (vtype_dict* x, const char* key, vtype_uint8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_uint16 (vtype_dict* x, const char* key, vtype_uint16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_uint32 (vtype_dict* x, const char* key, vtype_uint32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_uint64 (vtype_dict* x, const char* key, vtype_uint64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_float (vtype_dict* x, const char* key, vtype_float value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_double (vtype_dict* x, const char* key, vtype_double value) Nonnull__(1,2); -extern bool libcdsb_dict_update_cstring_ldouble(vtype_dict* x, const char* key, vtype_ldouble value) Nonnull__(1,2); - -extern bool libcdsb_dict_update_string_pointer(vtype_dict* x, const vtype_string* key, const void* value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_cstring(vtype_dict* x, const vtype_string* key, const char* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_string_string (vtype_dict* x, const vtype_string* key, const vtype_string* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_string_array (vtype_dict* x, const vtype_string* key, const vtype_array* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_string_list (vtype_dict* x, const vtype_string* key, const vtype_list* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_string_map (vtype_dict* x, const vtype_string* key, const vtype_map* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_string_vset (vtype_dict* x, const vtype_string* key, const vtype_set* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_string_dict (vtype_dict* x, const vtype_string* key, const vtype_dict* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_string_boolean(vtype_dict* x, const vtype_string* key, vtype_bool value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_int8 (vtype_dict* x, const vtype_string* key, vtype_int8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_int16 (vtype_dict* x, const vtype_string* key, vtype_int16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_int32 (vtype_dict* x, const vtype_string* key, vtype_int32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_int64 (vtype_dict* x, const vtype_string* key, vtype_int64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_uint8 (vtype_dict* x, const vtype_string* key, vtype_uint8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_uint16 (vtype_dict* x, const vtype_string* key, vtype_uint16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_uint32 (vtype_dict* x, const vtype_string* key, vtype_uint32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_uint64 (vtype_dict* x, const vtype_string* key, vtype_uint64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_float (vtype_dict* x, const vtype_string* key, vtype_float value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_double (vtype_dict* x, const vtype_string* key, vtype_double value) Nonnull__(1,2); -extern bool libcdsb_dict_update_string_ldouble(vtype_dict* x, const vtype_string* key, vtype_ldouble value) Nonnull__(1,2); - -extern bool libcdsb_dict_update_array_pointer(vtype_dict* x, const vtype_array* key, const void* value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_cstring(vtype_dict* x, const vtype_array* key, const char* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_array_string (vtype_dict* x, const vtype_array* key, const vtype_string* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_array_array (vtype_dict* x, const vtype_array* key, const vtype_array* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_array_list (vtype_dict* x, const vtype_array* key, const vtype_list* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_array_map (vtype_dict* x, const vtype_array* key, const vtype_map* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_array_vset (vtype_dict* x, const vtype_array* key, const vtype_set* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_array_dict (vtype_dict* x, const vtype_array* key, const vtype_dict* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_array_boolean(vtype_dict* x, const vtype_array* key, vtype_bool value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_int8 (vtype_dict* x, const vtype_array* key, vtype_int8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_int16 (vtype_dict* x, const vtype_array* key, vtype_int16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_int32 (vtype_dict* x, const vtype_array* key, vtype_int32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_int64 (vtype_dict* x, const vtype_array* key, vtype_int64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_uint8 (vtype_dict* x, const vtype_array* key, vtype_uint8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_uint16 (vtype_dict* x, const vtype_array* key, vtype_uint16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_uint32 (vtype_dict* x, const vtype_array* key, vtype_uint32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_uint64 (vtype_dict* x, const vtype_array* key, vtype_uint64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_float (vtype_dict* x, const vtype_array* key, vtype_float value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_double (vtype_dict* x, const vtype_array* key, vtype_double value) Nonnull__(1,2); -extern bool libcdsb_dict_update_array_ldouble(vtype_dict* x, const vtype_array* key, vtype_ldouble value) Nonnull__(1,2); - -extern bool libcdsb_dict_update_list_pointer(vtype_dict* x, const vtype_list* key, const void* value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_cstring(vtype_dict* x, const vtype_list* key, const char* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_list_string (vtype_dict* x, const vtype_list* key, const vtype_string* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_list_array (vtype_dict* x, const vtype_list* key, const vtype_array* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_list_list (vtype_dict* x, const vtype_list* key, const vtype_list* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_list_map (vtype_dict* x, const vtype_list* key, const vtype_map* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_list_vset (vtype_dict* x, const vtype_list* key, const vtype_set* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_list_dict (vtype_dict* x, const vtype_list* key, const vtype_dict* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_list_boolean(vtype_dict* x, const vtype_list* key, vtype_bool value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_int8 (vtype_dict* x, const vtype_list* key, vtype_int8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_int16 (vtype_dict* x, const vtype_list* key, vtype_int16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_int32 (vtype_dict* x, const vtype_list* key, vtype_int32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_int64 (vtype_dict* x, const vtype_list* key, vtype_int64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_uint8 (vtype_dict* x, const vtype_list* key, vtype_uint8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_uint16 (vtype_dict* x, const vtype_list* key, vtype_uint16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_uint32 (vtype_dict* x, const vtype_list* key, vtype_uint32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_uint64 (vtype_dict* x, const vtype_list* key, vtype_uint64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_float (vtype_dict* x, const vtype_list* key, vtype_float value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_double (vtype_dict* x, const vtype_list* key, vtype_double value) Nonnull__(1,2); -extern bool libcdsb_dict_update_list_ldouble(vtype_dict* x, const vtype_list* key, vtype_ldouble value) Nonnull__(1,2); - -extern bool libcdsb_dict_update_map_pointer(vtype_dict* x, const vtype_map* key, const void* value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_cstring(vtype_dict* x, const vtype_map* key, const char* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_map_string (vtype_dict* x, const vtype_map* key, const vtype_string* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_map_array (vtype_dict* x, const vtype_map* key, const vtype_array* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_map_list (vtype_dict* x, const vtype_map* key, const vtype_list* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_map_map (vtype_dict* x, const vtype_map* key, const vtype_map* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_map_vset (vtype_dict* x, const vtype_map* key, const vtype_set* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_map_dict (vtype_dict* x, const vtype_map* key, const vtype_dict* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_map_boolean(vtype_dict* x, const vtype_map* key, vtype_bool value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_int8 (vtype_dict* x, const vtype_map* key, vtype_int8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_int16 (vtype_dict* x, const vtype_map* key, vtype_int16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_int32 (vtype_dict* x, const vtype_map* key, vtype_int32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_int64 (vtype_dict* x, const vtype_map* key, vtype_int64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_uint8 (vtype_dict* x, const vtype_map* key, vtype_uint8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_uint16 (vtype_dict* x, const vtype_map* key, vtype_uint16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_uint32 (vtype_dict* x, const vtype_map* key, vtype_uint32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_uint64 (vtype_dict* x, const vtype_map* key, vtype_uint64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_float (vtype_dict* x, const vtype_map* key, vtype_float value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_double (vtype_dict* x, const vtype_map* key, vtype_double value) Nonnull__(1,2); -extern bool libcdsb_dict_update_map_ldouble(vtype_dict* x, const vtype_map* key, vtype_ldouble value) Nonnull__(1,2); - -extern bool libcdsb_dict_update_vset_pointer(vtype_dict* x, const vtype_set* key, const void* value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_cstring(vtype_dict* x, const vtype_set* key, const char* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_vset_string (vtype_dict* x, const vtype_set* key, const vtype_string* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_vset_array (vtype_dict* x, const vtype_set* key, const vtype_array* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_vset_list (vtype_dict* x, const vtype_set* key, const vtype_list* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_vset_map (vtype_dict* x, const vtype_set* key, const vtype_map* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_vset_vset (vtype_dict* x, const vtype_set* key, const vtype_set* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_vset_dict (vtype_dict* x, const vtype_set* key, const vtype_dict* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_vset_boolean(vtype_dict* x, const vtype_set* key, vtype_bool value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_int8 (vtype_dict* x, const vtype_set* key, vtype_int8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_int16 (vtype_dict* x, const vtype_set* key, vtype_int16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_int32 (vtype_dict* x, const vtype_set* key, vtype_int32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_int64 (vtype_dict* x, const vtype_set* key, vtype_int64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_uint8 (vtype_dict* x, const vtype_set* key, vtype_uint8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_uint16 (vtype_dict* x, const vtype_set* key, vtype_uint16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_uint32 (vtype_dict* x, const vtype_set* key, vtype_uint32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_uint64 (vtype_dict* x, const vtype_set* key, vtype_uint64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_float (vtype_dict* x, const vtype_set* key, vtype_float value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_double (vtype_dict* x, const vtype_set* key, vtype_double value) Nonnull__(1,2); -extern bool libcdsb_dict_update_vset_ldouble(vtype_dict* x, const vtype_set* key, vtype_ldouble value) Nonnull__(1,2); - -extern bool libcdsb_dict_update_dict_pointer(vtype_dict* x, const vtype_dict* key, const void* value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_cstring(vtype_dict* x, const vtype_dict* key, const char* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_dict_string (vtype_dict* x, const vtype_dict* key, const vtype_string* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_dict_array (vtype_dict* x, const vtype_dict* key, const vtype_array* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_dict_list (vtype_dict* x, const vtype_dict* key, const vtype_list* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_dict_map (vtype_dict* x, const vtype_dict* key, const vtype_map* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_dict_vset (vtype_dict* x, const vtype_dict* key, const vtype_set* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_dict_dict (vtype_dict* x, const vtype_dict* key, const vtype_dict* value) Nonnull__(1,2,3); -extern bool libcdsb_dict_update_dict_boolean(vtype_dict* x, const vtype_dict* key, vtype_bool value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_int8 (vtype_dict* x, const vtype_dict* key, vtype_int8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_int16 (vtype_dict* x, const vtype_dict* key, vtype_int16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_int32 (vtype_dict* x, const vtype_dict* key, vtype_int32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_int64 (vtype_dict* x, const vtype_dict* key, vtype_int64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_uint8 (vtype_dict* x, const vtype_dict* key, vtype_uint8 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_uint16 (vtype_dict* x, const vtype_dict* key, vtype_uint16 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_uint32 (vtype_dict* x, const vtype_dict* key, vtype_uint32 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_uint64 (vtype_dict* x, const vtype_dict* key, vtype_uint64 value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_float (vtype_dict* x, const vtype_dict* key, vtype_float value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_double (vtype_dict* x, const vtype_dict* key, vtype_double value) Nonnull__(1,2); -extern bool libcdsb_dict_update_dict_ldouble(vtype_dict* x, const vtype_dict* key, vtype_ldouble value) Nonnull__(1,2); - -extern bool libcdsb_dict_update_boolean_pointer(vtype_dict* x, vtype_bool key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_cstring(vtype_dict* x, vtype_bool key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_boolean_string (vtype_dict* x, vtype_bool key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_boolean_array (vtype_dict* x, vtype_bool key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_boolean_list (vtype_dict* x, vtype_bool key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_boolean_map (vtype_dict* x, vtype_bool key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_boolean_vset (vtype_dict* x, vtype_bool key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_boolean_dict (vtype_dict* x, vtype_bool key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_boolean_boolean(vtype_dict* x, vtype_bool key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_int8 (vtype_dict* x, vtype_bool key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_int16 (vtype_dict* x, vtype_bool key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_int32 (vtype_dict* x, vtype_bool key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_int64 (vtype_dict* x, vtype_bool key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_uint8 (vtype_dict* x, vtype_bool key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_uint16 (vtype_dict* x, vtype_bool key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_uint32 (vtype_dict* x, vtype_bool key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_uint64 (vtype_dict* x, vtype_bool key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_float (vtype_dict* x, vtype_bool key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_double (vtype_dict* x, vtype_bool key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_boolean_ldouble(vtype_dict* x, vtype_bool key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_uint8_pointer(vtype_dict* x, vtype_uint8 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_cstring(vtype_dict* x, vtype_uint8 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint8_string (vtype_dict* x, vtype_uint8 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint8_array (vtype_dict* x, vtype_uint8 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint8_list (vtype_dict* x, vtype_uint8 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint8_map (vtype_dict* x, vtype_uint8 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint8_vset (vtype_dict* x, vtype_uint8 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint8_dict (vtype_dict* x, vtype_uint8 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint8_boolean(vtype_dict* x, vtype_uint8 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_int8 (vtype_dict* x, vtype_uint8 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_int16 (vtype_dict* x, vtype_uint8 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_int32 (vtype_dict* x, vtype_uint8 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_int64 (vtype_dict* x, vtype_uint8 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_uint8 (vtype_dict* x, vtype_uint8 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_uint16 (vtype_dict* x, vtype_uint8 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_uint32 (vtype_dict* x, vtype_uint8 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_uint64 (vtype_dict* x, vtype_uint8 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_float (vtype_dict* x, vtype_uint8 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_double (vtype_dict* x, vtype_uint8 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_uint8_ldouble(vtype_dict* x, vtype_uint8 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_uint16_pointer(vtype_dict* x, vtype_uint16 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_cstring(vtype_dict* x, vtype_uint16 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint16_string (vtype_dict* x, vtype_uint16 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint16_array (vtype_dict* x, vtype_uint16 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint16_list (vtype_dict* x, vtype_uint16 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint16_map (vtype_dict* x, vtype_uint16 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint16_vset (vtype_dict* x, vtype_uint16 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint16_dict (vtype_dict* x, vtype_uint16 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint16_boolean(vtype_dict* x, vtype_uint16 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_int8 (vtype_dict* x, vtype_uint16 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_int16 (vtype_dict* x, vtype_uint16 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_int32 (vtype_dict* x, vtype_uint16 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_int64 (vtype_dict* x, vtype_uint16 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_uint8 (vtype_dict* x, vtype_uint16 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_uint16 (vtype_dict* x, vtype_uint16 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_uint32 (vtype_dict* x, vtype_uint16 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_uint64 (vtype_dict* x, vtype_uint16 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_float (vtype_dict* x, vtype_uint16 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_double (vtype_dict* x, vtype_uint16 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_uint16_ldouble(vtype_dict* x, vtype_uint16 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_uint32_pointer(vtype_dict* x, vtype_uint32 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_cstring(vtype_dict* x, vtype_uint32 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint32_string (vtype_dict* x, vtype_uint32 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint32_array (vtype_dict* x, vtype_uint32 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint32_list (vtype_dict* x, vtype_uint32 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint32_map (vtype_dict* x, vtype_uint32 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint32_vset (vtype_dict* x, vtype_uint32 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint32_dict (vtype_dict* x, vtype_uint32 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint32_boolean(vtype_dict* x, vtype_uint32 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_int8 (vtype_dict* x, vtype_uint32 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_int16 (vtype_dict* x, vtype_uint32 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_int32 (vtype_dict* x, vtype_uint32 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_int64 (vtype_dict* x, vtype_uint32 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_uint8 (vtype_dict* x, vtype_uint32 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_uint16 (vtype_dict* x, vtype_uint32 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_uint32 (vtype_dict* x, vtype_uint32 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_uint64 (vtype_dict* x, vtype_uint32 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_float (vtype_dict* x, vtype_uint32 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_double (vtype_dict* x, vtype_uint32 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_uint32_ldouble(vtype_dict* x, vtype_uint32 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_uint64_pointer(vtype_dict* x, vtype_uint64 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_cstring(vtype_dict* x, vtype_uint64 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint64_string (vtype_dict* x, vtype_uint64 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint64_array (vtype_dict* x, vtype_uint64 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint64_list (vtype_dict* x, vtype_uint64 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint64_map (vtype_dict* x, vtype_uint64 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint64_vset (vtype_dict* x, vtype_uint64 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint64_dict (vtype_dict* x, vtype_uint64 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_uint64_boolean(vtype_dict* x, vtype_uint64 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_int8 (vtype_dict* x, vtype_uint64 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_int16 (vtype_dict* x, vtype_uint64 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_int32 (vtype_dict* x, vtype_uint64 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_int64 (vtype_dict* x, vtype_uint64 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_uint8 (vtype_dict* x, vtype_uint64 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_uint16 (vtype_dict* x, vtype_uint64 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_uint32 (vtype_dict* x, vtype_uint64 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_uint64 (vtype_dict* x, vtype_uint64 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_float (vtype_dict* x, vtype_uint64 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_double (vtype_dict* x, vtype_uint64 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_uint64_ldouble(vtype_dict* x, vtype_uint64 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_int8_pointer(vtype_dict* x, vtype_int8 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_cstring(vtype_dict* x, vtype_int8 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int8_string (vtype_dict* x, vtype_int8 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int8_array (vtype_dict* x, vtype_int8 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int8_list (vtype_dict* x, vtype_int8 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int8_map (vtype_dict* x, vtype_int8 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int8_vset (vtype_dict* x, vtype_int8 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int8_dict (vtype_dict* x, vtype_int8 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int8_boolean(vtype_dict* x, vtype_int8 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_int8 (vtype_dict* x, vtype_int8 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_int16 (vtype_dict* x, vtype_int8 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_int32 (vtype_dict* x, vtype_int8 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_int64 (vtype_dict* x, vtype_int8 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_uint8 (vtype_dict* x, vtype_int8 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_uint16 (vtype_dict* x, vtype_int8 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_uint32 (vtype_dict* x, vtype_int8 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_uint64 (vtype_dict* x, vtype_int8 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_float (vtype_dict* x, vtype_int8 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_double (vtype_dict* x, vtype_int8 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_int8_ldouble(vtype_dict* x, vtype_int8 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_int16_pointer(vtype_dict* x, vtype_int16 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_cstring(vtype_dict* x, vtype_int16 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int16_string (vtype_dict* x, vtype_int16 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int16_array (vtype_dict* x, vtype_int16 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int16_list (vtype_dict* x, vtype_int16 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int16_map (vtype_dict* x, vtype_int16 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int16_vset (vtype_dict* x, vtype_int16 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int16_dict (vtype_dict* x, vtype_int16 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int16_boolean(vtype_dict* x, vtype_int16 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_int8 (vtype_dict* x, vtype_int16 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_int16 (vtype_dict* x, vtype_int16 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_int32 (vtype_dict* x, vtype_int16 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_int64 (vtype_dict* x, vtype_int16 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_uint8 (vtype_dict* x, vtype_int16 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_uint16 (vtype_dict* x, vtype_int16 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_uint32 (vtype_dict* x, vtype_int16 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_uint64 (vtype_dict* x, vtype_int16 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_float (vtype_dict* x, vtype_int16 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_double (vtype_dict* x, vtype_int16 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_int16_ldouble(vtype_dict* x, vtype_int16 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_int32_pointer(vtype_dict* x, vtype_int32 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_cstring(vtype_dict* x, vtype_int32 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int32_string (vtype_dict* x, vtype_int32 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int32_array (vtype_dict* x, vtype_int32 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int32_list (vtype_dict* x, vtype_int32 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int32_map (vtype_dict* x, vtype_int32 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int32_vset (vtype_dict* x, vtype_int32 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int32_dict (vtype_dict* x, vtype_int32 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int32_boolean(vtype_dict* x, vtype_int32 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_int8 (vtype_dict* x, vtype_int32 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_int16 (vtype_dict* x, vtype_int32 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_int32 (vtype_dict* x, vtype_int32 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_int64 (vtype_dict* x, vtype_int32 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_uint8 (vtype_dict* x, vtype_int32 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_uint16 (vtype_dict* x, vtype_int32 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_uint32 (vtype_dict* x, vtype_int32 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_uint64 (vtype_dict* x, vtype_int32 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_float (vtype_dict* x, vtype_int32 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_double (vtype_dict* x, vtype_int32 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_int32_ldouble(vtype_dict* x, vtype_int32 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_int64_pointer(vtype_dict* x, vtype_int64 key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_cstring(vtype_dict* x, vtype_int64 key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int64_string (vtype_dict* x, vtype_int64 key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int64_array (vtype_dict* x, vtype_int64 key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int64_list (vtype_dict* x, vtype_int64 key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int64_map (vtype_dict* x, vtype_int64 key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int64_vset (vtype_dict* x, vtype_int64 key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int64_dict (vtype_dict* x, vtype_int64 key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_int64_boolean(vtype_dict* x, vtype_int64 key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_int8 (vtype_dict* x, vtype_int64 key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_int16 (vtype_dict* x, vtype_int64 key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_int32 (vtype_dict* x, vtype_int64 key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_int64 (vtype_dict* x, vtype_int64 key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_uint8 (vtype_dict* x, vtype_int64 key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_uint16 (vtype_dict* x, vtype_int64 key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_uint32 (vtype_dict* x, vtype_int64 key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_uint64 (vtype_dict* x, vtype_int64 key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_float (vtype_dict* x, vtype_int64 key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_double (vtype_dict* x, vtype_int64 key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_int64_ldouble(vtype_dict* x, vtype_int64 key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_float_pointer(vtype_dict* x, vtype_float key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_float_cstring(vtype_dict* x, vtype_float key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_float_string (vtype_dict* x, vtype_float key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_float_array (vtype_dict* x, vtype_float key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_float_list (vtype_dict* x, vtype_float key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_float_map (vtype_dict* x, vtype_float key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_float_vset (vtype_dict* x, vtype_float key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_float_dict (vtype_dict* x, vtype_float key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_float_boolean(vtype_dict* x, vtype_float key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_float_int8 (vtype_dict* x, vtype_float key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_int16 (vtype_dict* x, vtype_float key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_int32 (vtype_dict* x, vtype_float key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_int64 (vtype_dict* x, vtype_float key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_uint8 (vtype_dict* x, vtype_float key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_uint16 (vtype_dict* x, vtype_float key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_uint32 (vtype_dict* x, vtype_float key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_uint64 (vtype_dict* x, vtype_float key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_float_float (vtype_dict* x, vtype_float key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_float_double (vtype_dict* x, vtype_float key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_float_ldouble(vtype_dict* x, vtype_float key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_double_pointer(vtype_dict* x, vtype_double key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_double_cstring(vtype_dict* x, vtype_double key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_double_string (vtype_dict* x, vtype_double key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_double_array (vtype_dict* x, vtype_double key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_double_list (vtype_dict* x, vtype_double key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_double_map (vtype_dict* x, vtype_double key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_double_vset (vtype_dict* x, vtype_double key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_double_dict (vtype_dict* x, vtype_double key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_double_boolean(vtype_dict* x, vtype_double key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_double_int8 (vtype_dict* x, vtype_double key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_int16 (vtype_dict* x, vtype_double key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_int32 (vtype_dict* x, vtype_double key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_int64 (vtype_dict* x, vtype_double key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_uint8 (vtype_dict* x, vtype_double key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_uint16 (vtype_dict* x, vtype_double key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_uint32 (vtype_dict* x, vtype_double key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_uint64 (vtype_dict* x, vtype_double key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_double_float (vtype_dict* x, vtype_double key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_double_double (vtype_dict* x, vtype_double key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_double_ldouble(vtype_dict* x, vtype_double key, vtype_ldouble value) Nonnull__(1); - -extern bool libcdsb_dict_update_ldouble_pointer(vtype_dict* x, vtype_ldouble key, const void* value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_cstring(vtype_dict* x, vtype_ldouble key, const char* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_ldouble_string (vtype_dict* x, vtype_ldouble key, const vtype_string* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_ldouble_array (vtype_dict* x, vtype_ldouble key, const vtype_array* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_ldouble_list (vtype_dict* x, vtype_ldouble key, const vtype_list* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_ldouble_map (vtype_dict* x, vtype_ldouble key, const vtype_map* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_ldouble_vset (vtype_dict* x, vtype_ldouble key, const vtype_set* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_ldouble_dict (vtype_dict* x, vtype_ldouble key, const vtype_dict* value) Nonnull__(1,3); -extern bool libcdsb_dict_update_ldouble_boolean(vtype_dict* x, vtype_ldouble key, vtype_bool value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_int8 (vtype_dict* x, vtype_ldouble key, vtype_int8 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_int16 (vtype_dict* x, vtype_ldouble key, vtype_int16 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_int32 (vtype_dict* x, vtype_ldouble key, vtype_int32 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_int64 (vtype_dict* x, vtype_ldouble key, vtype_int64 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_uint8 (vtype_dict* x, vtype_ldouble key, vtype_uint8 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_uint16 (vtype_dict* x, vtype_ldouble key, vtype_uint16 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_uint32 (vtype_dict* x, vtype_ldouble key, vtype_uint32 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_uint64 (vtype_dict* x, vtype_ldouble key, vtype_uint64 value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_float (vtype_dict* x, vtype_ldouble key, vtype_float value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_double (vtype_dict* x, vtype_ldouble key, vtype_double value) Nonnull__(1); -extern bool libcdsb_dict_update_ldouble_ldouble(vtype_dict* x, vtype_ldouble key, vtype_ldouble value) Nonnull__(1); +extern bool libcdsb_dict_update (vtype_dict* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); +extern bool libcdsb_dict_inject (vtype_dict* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); +extern bool libcdsb_dict_inject_key (vtype_dict* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); +extern bool libcdsb_dict_inject_value (vtype_dict* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); +extern int libcdsb_dict_find (vtype_dict* x, const void* key, vtype key_type, void* data, dict_access_callback, bool cut) Nonnull__(1); +extern int libcdsb_dict_foreach (vtype_dict* x, void* data, dict_access_callback, bool flush) Nonnull__(1,3); +extern bool libcdsb_dict_shrink_to_fit(vtype_dict* x) Nonnull__(1); #endif /* LIBCDSB_DICT_H */ diff --git a/include/extra/dict.h b/include/extra/dict.h deleted file mode 100644 index 1f8edc5..0000000 --- a/include/extra/dict.h +++ /dev/null @@ -1,29 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "../dict.h" - -#ifndef LIBCDSB_EXTRA_DICT_H -#define LIBCDSB_EXTRA_DICT_H - -#define dict_foreach(x, data, callback) libcdsb_dict_foreach(x, data, callback, 0) - -extern bool libcdsb_dict_update (vtype_dict* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1); -extern int libcdsb_dict_find (vtype_dict* x, const void* key, vtype key_type, void* data, dict_access_callback, bool cut) Nonnull__(1); -extern int libcdsb_dict_foreach (vtype_dict* x, void* data, dict_access_callback, bool flush) Nonnull__(1,3); -extern bool libcdsb_dict_shrink_to_fit(vtype_dict* x) Nonnull__(1); - -#endif /* LIBCDSB_EXTRA_DICT_H */ - -#if defined(LIBCDSB_LIST_H) && !defined(LIBCDSB_EXTRA_DICT_H_EXT) -#define LIBCDSB_EXTRA_DICT_H_EXT - -#define dict_copy_keys libcdsb_dict_copy_keys -#define dict_duplicate_keys libcdsb_dict_duplicate_keys -#define dict_init_keys libcdsb_dict_init_keys - -extern vtype_list libcdsb_dict_copy_keys (const vtype_dict* s) Nonnull__(1); -extern vtype_list* libcdsb_dict_duplicate_keys(const vtype_dict* s) Nonnull__(1); -extern void libcdsb_dict_init_keys (vtype_list* x, const vtype_dict* s) Nonnull__(1,2); - -#endif /* LIBCDSB_EXTRA_DICT_H_EXT */ diff --git a/include/vtype.h b/include/vtype.h index 19fbee9..e3328f8 100644 --- a/include/vtype.h +++ b/include/vtype.h @@ -86,20 +86,22 @@ extern int map_compare (const vtype_map* s0, const vtype_map* s1) Pure__ extern int vset_compare (const vtype_set* s0, const vtype_set* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); extern int dict_compare (const vtype_dict* s0, const vtype_dict* s1) Pure__ Warn_unused_result__ Nonnull__(1,2); -extern vtype_string string_copy (const vtype_string* s) Pure__ Warn_unused_result__ Nonnull__(1); -extern vtype_array array_copy (const vtype_array* s) Pure__ Warn_unused_result__ Nonnull__(1); -extern vtype_list list_copy (const vtype_list* s) Pure__ Warn_unused_result__ Nonnull__(1); -extern vtype_map map_copy (const vtype_map* s) Pure__ Warn_unused_result__ Nonnull__(1); -extern vtype_set vset_copy (const vtype_set* s) Pure__ Warn_unused_result__ Nonnull__(1); -extern vtype_dict dict_copy (const vtype_dict* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern vtype_string string_copy (const vtype_string* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern vtype_array array_copy (const vtype_array* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern vtype_list list_copy (const vtype_list* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern vtype_map map_copy (const vtype_map* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern vtype_set vset_copy (const vtype_set* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern vtype_dict dict_copy (const vtype_dict* s) Pure__ Warn_unused_result__ Nonnull__(1); +extern vtype_list dict_copy_keys(const vtype_dict* s) Pure__ Warn_unused_result__ Nonnull__(1); #define map_copy_keys(s) vset_copy((vtype_set*)s) -extern vtype_string* string_duplicate (const vtype_string* s) Warn_unused_result__ Nonnull__(1); -extern vtype_array* array_duplicate (const vtype_array* s) Warn_unused_result__ Nonnull__(1); -extern vtype_list* list_duplicate (const vtype_list* s) Warn_unused_result__ Nonnull__(1); -extern vtype_map* map_duplicate (const vtype_map* s) Warn_unused_result__ Nonnull__(1); -extern vtype_set* vset_duplicate (const vtype_set* s) Warn_unused_result__ Nonnull__(1); -extern vtype_dict* dict_duplicate (const vtype_dict* s) Warn_unused_result__ Nonnull__(1); +extern vtype_string* string_duplicate (const vtype_string* s) Warn_unused_result__ Nonnull__(1); +extern vtype_array* array_duplicate (const vtype_array* s) Warn_unused_result__ Nonnull__(1); +extern vtype_list* list_duplicate (const vtype_list* s) Warn_unused_result__ Nonnull__(1); +extern vtype_map* map_duplicate (const vtype_map* s) Warn_unused_result__ Nonnull__(1); +extern vtype_set* vset_duplicate (const vtype_set* s) Warn_unused_result__ Nonnull__(1); +extern vtype_dict* dict_duplicate (const vtype_dict* s) Warn_unused_result__ Nonnull__(1); +extern vtype_list* dict_duplicate_keys(const vtype_dict* s) Warn_unused_result__ Nonnull__(1); #define map_duplicate_keys(s) vset_duplicate((vtype_set*)s) extern void string_copy_init (vtype_string* x, const vtype_string* s) Nonnull__(1,2); @@ -108,6 +110,7 @@ extern void list_copy_init (vtype_list* x, const vtype_list* s) Nonnull__ extern void map_copy_init (vtype_map* x, const vtype_map* s) Nonnull__(1,2); extern void vset_copy_init (vtype_set* x, const vtype_set* s) Nonnull__(1,2); extern void dict_copy_init (vtype_dict* x, const vtype_dict* s) Nonnull__(1,2); +extern void dict_init_keys (vtype_list* x, const vtype_dict* s) Nonnull__(1,2); #define map_copy_init_keys(x, s) vset_duplicate(x, (vtype_set*)s) extern void string_free(vtype_string* x); diff --git a/src/dict/access.c b/src/dict/access.c new file mode 100644 index 0000000..596fbb6 --- /dev/null +++ b/src/dict/access.c @@ -0,0 +1,87 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +int libcdsb_dict_find(dict_t* x, const void* k, vtype t, void* dt, dict_access_callback callback, bool cut) { + dnode_t *c, **p; + int r; + void* key; + + if (x->capacity) { + c = *(p = x->nodes + (vtype_hash(k, t) % x->capacity)); + + while (!is_null(c)) { + key = vnode_peek(&c->key, c->key_type); + if (vtype_compare(k, t, key, c->key_type) == 0) { + r = (callback) ? callback(key, c->key_type, vnode_peek(&c->value, c->value_type), c->value_type, dt) : 0; + + if (cut) { + *p = c->prev; + vnode_free(&c->key, c->key_type); + vnode_free(&c->value, c->value_type); + free(c); + --x->size; + } + + return r; + } else c = *(p = &c->prev); + } + } + + return -1; +} + + +int libcdsb_dict_foreach(dict_t* x, void* dt, dict_access_callback callback, bool flush) { + dnode_t *c; + ssize_t i; + int r; + + r = 0; + i = x->capacity; + + while (i) { + c = x->nodes[--i]; + + while (!is_null(c)) { + r = callback(vnode_peek(&c->key, c->key_type), c->key_type, + vnode_peek(&c->value, c->value_type), c->value_type, dt); + + c = c->prev; + + if (r) { + if (!flush) goto end_; + else goto flush_loop_; + } else if (flush) { + vnode_free(&x->nodes[i]->key, x->nodes[i]->key_type); + vnode_free(&x->nodes[i]->value, x->nodes[i]->value_type); + free(x->nodes[i]); + + x->nodes[i] = c; + } + } + } + + if (flush) { + while (i) { + --i; + + while (!is_null(x->nodes[i])) { flush_loop_: + vnode_free(&x->nodes[i]->key, x->nodes[i]->key_type); + vnode_free(&x->nodes[i]->value, x->nodes[i]->value_type); + + c = x->nodes[i]->prev; + free(x->nodes[i]); + + x->nodes[i] = c; + } + } + + free(x->nodes); + memset(x, 0, sizeof(*x)); + } + + end_: + return r; +} diff --git a/src/dict/base.c b/src/dict/base.c deleted file mode 100644 index 76f7632..0000000 --- a/src/dict/base.c +++ /dev/null @@ -1,111 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "include.h" - -/*#####################################################################################################################*/ - -hash_t dict_hash(const dict_t* s) { - dnode_t *min, *max; - size_t i; - dnode_t *c; - hash_t hash; - - if (!s->size) - return 0; - - min = max = nullptr; - i = s->capacity; - - while (i--) { - c = s->nodes[i]; - - while (!is_null(c)) { - if (is_null(min) || vnode_compare(&c->key, c->key_type, &min->key, min->key_type) < 0) min = c; - if (is_null(max) || vnode_compare(&c->key, c->key_type, &max->key, max->key_type) > 0) max = c; - - c = c->prev; - } - } - - hash = vnode_hash(&min->key, min->key_type); - - if (s->size > 0) - hash += vnode_hash(&max->key, max->key_type); - - return (hash ^ s->size) + VTYPE_DICT; -} - - -void dict_init(dict_t* x) { - memset(x, 0, sizeof(*x)); -} - -/*#####################################################################################################################*/ - -void dict_free(dict_t* x) { - - while (x->capacity--) { - while (!is_null(x->nodes[x->capacity])) { - vnode_free(&x->nodes[x->capacity]->key, x->nodes[x->capacity]->key_type); - vnode_free(&x->nodes[x->capacity]->value, x->nodes[x->capacity]->value_type); - - x->nodes[x->capacity] = x->nodes[x->capacity]->prev; - } - } - - free(x->nodes); - memset(x, 0, sizeof(*x)); -} - -/*#####################################################################################################################*/ - -size_t dict_size(const dict_t* x) { - return x->size; -} - -size_t dict_capacity(const dict_t* x) { - return x->capacity; -} - -/*#####################################################################################################################*/ - -int dict_compare(const dict_t* s0, const dict_t* s1) { - dnode_t *c0, *c1; - size_t i; - int cmp; - - if (s0 == s1) - return 0; - - if (s0->size != s1->size) - return s0->size < s1->size ? -1 : 1; - - i = s0->capacity; - - while (i--) { - c0 = s0->nodes[i]; - - while (!is_null(c0)) { - - c1 = s1->nodes[vnode_hash(&c0->key, c0->key_type) % s1->capacity]; - cmp = -1; - - while (!is_null(c1)) { - if ((cmp = vnode_compare(&c0->key, c0->key_type, &c1->key, c1->key_type) == 0)) { - - cmp = vnode_compare(&c0->value, c0->value_type, &c1->value, c1->value_type); - break; - } - - c1 = c1->prev; - } - - if (cmp) return cmp; - - c0 = c0->prev; - } - } - - return 0; -} diff --git a/src/dict/comparison.c b/src/dict/comparison.c new file mode 100644 index 0000000..346651b --- /dev/null +++ b/src/dict/comparison.c @@ -0,0 +1,44 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +int dict_compare(const dict_t* s0, const dict_t* s1) { + dnode_t *c0, *c1; + size_t i; + int cmp; + + if (s0 == s1) + return 0; + + if (s0->size != s1->size) + return s0->size < s1->size ? -1 : 1; + + i = s0->capacity; + + while (i--) { + c0 = s0->nodes[i]; + + while (!is_null(c0)) { + + c1 = s1->nodes[vnode_hash(&c0->key, c0->key_type) % s1->capacity]; + cmp = -1; + + while (!is_null(c1)) { + if ((cmp = vnode_compare(&c0->key, c0->key_type, &c1->key, c1->key_type) == 0)) { + + cmp = vnode_compare(&c0->value, c0->value_type, &c1->value, c1->value_type); + break; + } + + c1 = c1->prev; + } + + if (cmp) return cmp; + + c0 = c0->prev; + } + } + + return 0; +} diff --git a/src/dict/compute.c b/src/dict/compute.c new file mode 100644 index 0000000..2750de4 --- /dev/null +++ b/src/dict/compute.c @@ -0,0 +1,45 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +size_t dict_size(const dict_t* x) { + return x->size; +} + + +size_t dict_capacity(const dict_t* x) { + return x->capacity; +} + + +hash_t dict_hash(const dict_t* s) { + dnode_t *min, *max; + size_t i; + dnode_t *c; + hash_t hash; + + if (!s->size) + return 0; + + min = max = nullptr; + i = s->capacity; + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + if (is_null(min) || vnode_compare(&c->key, c->key_type, &min->key, min->key_type) < 0) min = c; + if (is_null(max) || vnode_compare(&c->key, c->key_type, &max->key, max->key_type) > 0) max = c; + + c = c->prev; + } + } + + hash = vnode_hash(&min->key, min->key_type); + + if (s->size > 0) + hash += vnode_hash(&max->key, max->key_type); + + return (hash ^ s->size) + VTYPE_DICT; +} diff --git a/src/dict/copy.c b/src/dict/copy.c index 35931a7..a9a6148 100644 --- a/src/dict/copy.c +++ b/src/dict/copy.c @@ -1,10 +1,9 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ +#include "../../include/list.h" #include "include.h" -/*#####################################################################################################################*/ - static inline dnode_t* dnode_duplicate(const dnode_t* s, dnode_t* p) { dnode_t* x = malloc(sizeof(*x)); @@ -80,3 +79,68 @@ void dict_copy_init(dict_t* x, const dict_t* s) { } } } + + +vtype_list libcdsb_dict_copy_keys(const vtype_dict* s) { + vtype_list x; + dnode_t *c; + size_t i; + + i = s->capacity; + + list_init(&x); + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + libcdsb_list_insert(&x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); + c = c->prev; + } + } + + return x; +} + + +vtype_list* libcdsb_dict_duplicate_keys(const vtype_dict* s) { + vtype_list* x; + dnode_t *c; + size_t i; + + x = malloc(sizeof(*x)); + i = s->capacity; + + list_init(x); + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + libcdsb_list_insert(x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); + c = c->prev; + } + } + + return x; +} + + +void libcdsb_dict_init_keys(vtype_list* x, const vtype_dict* s) { + dnode_t *c; + size_t i; + + x = malloc(sizeof(*x)); + i = s->capacity; + + list_init(x); + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + libcdsb_list_insert(x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); + c = c->prev; + } + } +} diff --git a/src/dict/extra.c b/src/dict/extra.c deleted file mode 100644 index 5732977..0000000 --- a/src/dict/extra.c +++ /dev/null @@ -1,236 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "../../include/extra/list.h" -#include "include.h" - -/*#####################################################################################################################*/ - -static void dict_rehash(dict_t* s, size_t capacity) { - dnode_t **nodes, *c, *n, **p; - size_t i; - - i = s->capacity; - nodes = calloc(sizeof(*nodes), capacity); - - while (i--) { - c = s->nodes[i]; - - while (!is_null(c)) { - p = nodes + (vnode_hash(&c->key, c->key_type) % capacity); - n = c->prev; - c->prev = *p; - - *p = c; - c = n; - } - } - - free(s->nodes); - s->nodes = nodes; - s->capacity = capacity; -} - -/*#####################################################################################################################*/ - -bool libcdsb_dict_shrink_to_fit(dict_t* s) { - - size_t capacity; - - capacity = (s->size / CAPACITY_BLOCK) + 1; - capacity *= CAPACITY_BLOCK; - - while (((double)s->size / capacity) > 0.65) - capacity += CAPACITY_BLOCK; - - if (capacity >= s->capacity) - return false; - - dict_rehash(s, capacity); - - return true; -} - - -bool libcdsb_dict_update(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { - dnode_t *c, **p; - - if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) - dict_rehash(x, x->capacity + CAPACITY_BLOCK); - - c = *(p = x->nodes + (vtype_hash(k, kt) % x->capacity)); - - while (!is_null(c)) { - if (vtype_compare(k, kt, vnode_peek(&c->key, c->key_type), c->key_type) == 0) { - vnode_free(&c->value, c->value_type); - - c->value = vnode_create(v, vt); - c->value_type = vt; - - return true; - } else c = c->prev; - } - - c = malloc(sizeof(*c)); - - c->prev = *p; - c->key = vnode_create(k, kt); - c->value = vnode_create(v, vt); - c->key_type = kt; - c->value_type = vt; - - *p = c; - ++x->size; - - return false; -} - - -int libcdsb_dict_find(dict_t* x, const void* k, vtype t, void* dt, dict_access_callback callback, bool cut) { - dnode_t *c, **p; - int r; - void* key; - - if (x->capacity) { - c = *(p = x->nodes + (vtype_hash(k, t) % x->capacity)); - - while (!is_null(c)) { - key = vnode_peek(&c->key, c->key_type); - if (vtype_compare(k, t, key, c->key_type) == 0) { - r = (callback) ? callback(key, c->key_type, vnode_peek(&c->value, c->value_type), c->value_type, dt) : 0; - - if (cut) { - *p = c->prev; - vnode_free(&c->key, c->key_type); - vnode_free(&c->value, c->value_type); - free(c); - --x->size; - } - - return r; - } else c = *(p = &c->prev); - } - } - - return -1; -} - - -int libcdsb_dict_foreach(dict_t* x, void* dt, dict_access_callback callback, bool flush) { - dnode_t *c; - ssize_t i; - int r; - - r = 0; - i = x->capacity; - - while (i) { - c = x->nodes[--i]; - - while (!is_null(c)) { - r = callback(vnode_peek(&c->key, c->key_type), c->key_type, - vnode_peek(&c->value, c->value_type), c->value_type, dt); - - c = c->prev; - - if (r) { - if (!flush) goto end_; - else goto flush_loop_; - } else if (flush) { - vnode_free(&x->nodes[i]->key, x->nodes[i]->key_type); - vnode_free(&x->nodes[i]->value, x->nodes[i]->value_type); - free(x->nodes[i]); - - x->nodes[i] = c; - } - } - } - - if (flush) { - while (i) { - --i; - - while (!is_null(x->nodes[i])) { flush_loop_: - vnode_free(&x->nodes[i]->key, x->nodes[i]->key_type); - vnode_free(&x->nodes[i]->value, x->nodes[i]->value_type); - - c = x->nodes[i]->prev; - free(x->nodes[i]); - - x->nodes[i] = c; - } - } - - free(x->nodes); - memset(x, 0, sizeof(*x)); - } - - end_: - return r; -} - -/*#####################################################################################################################*/ - -vtype_list libcdsb_dict_copy_keys(const vtype_dict* s) { - vtype_list x; - dnode_t *c; - size_t i; - - i = s->capacity; - - list_init(&x); - - while (i--) { - c = s->nodes[i]; - - while (!is_null(c)) { - libcdsb_list_update(&x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); - c = c->prev; - } - } - - return x; -} - - -vtype_list* libcdsb_dict_duplicate_keys(const vtype_dict* s) { - vtype_list* x; - dnode_t *c; - size_t i; - - x = malloc(sizeof(*x)); - i = s->capacity; - - list_init(x); - - while (i--) { - c = s->nodes[i]; - - while (!is_null(c)) { - libcdsb_list_update(x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); - c = c->prev; - } - } - - return x; -} - - -void libcdsb_dict_init_keys(vtype_list* x, const vtype_dict* s) { - dnode_t *c; - size_t i; - - x = malloc(sizeof(*x)); - i = s->capacity; - - list_init(x); - - while (i--) { - c = s->nodes[i]; - - while (!is_null(c)) { - libcdsb_list_update(x, -1, vnode_peek(&c->key, c->key_type), c->key_type, 1); - c = c->prev; - } - } -} diff --git a/src/dict/generics.c b/src/dict/generics.c deleted file mode 100644 index 41ab6b0..0000000 --- a/src/dict/generics.c +++ /dev/null @@ -1,445 +0,0 @@ -/* This software is licensed by the MIT License, see LICENSE file */ -/* Copyright © 2022 Gregory Lirent */ - -#include "include.h" - -int libcdsb_dict_find_by_pointer(dict_t* x, const void* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_cstring(dict_t* x, const char* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_string (dict_t* x, const str_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_find_by_array (dict_t* x, const arr_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_find_by_list (dict_t* x, const list_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_find_by_map (dict_t* x, const map_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_find_by_vset (dict_t* x, const set_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_find_by_dict (dict_t* x, const dict_t* k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, k, vtypeof( k), _, cb, cut); } -int libcdsb_dict_find_by_boolean(dict_t* x, bool k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_int8 (dict_t* x, s8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_int16 (dict_t* x, s16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_int32 (dict_t* x, s32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_int64 (dict_t* x, s64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_uint8 (dict_t* x, u8_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_uint16 (dict_t* x, u16_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_uint32 (dict_t* x, u32_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_uint64 (dict_t* x, u64_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_float (dict_t* x, fl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_double (dict_t* x, dbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } -int libcdsb_dict_find_by_ldouble(dict_t* x, ldbl_t k, void* _, dict_access_callback cb, bool cut) { return libcdsb_dict_find(x, &k, vtypeof(&k), _, cb, cut); } - -bool libcdsb_dict_update_pointer_pointer(dict_t* x, const void* k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_cstring(dict_t* x, const void* k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_string (dict_t* x, const void* k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_pointer_array (dict_t* x, const void* k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_pointer_list (dict_t* x, const void* k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_pointer_map (dict_t* x, const void* k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_pointer_vset (dict_t* x, const void* k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_pointer_dict (dict_t* x, const void* k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_pointer_boolean(dict_t* x, const void* k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_int8 (dict_t* x, const void* k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_int16 (dict_t* x, const void* k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_int32 (dict_t* x, const void* k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_int64 (dict_t* x, const void* k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_uint8 (dict_t* x, const void* k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_uint16 (dict_t* x, const void* k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_uint32 (dict_t* x, const void* k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_uint64 (dict_t* x, const void* k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_float (dict_t* x, const void* k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_double (dict_t* x, const void* k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_pointer_ldouble(dict_t* x, const void* k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_cstring_pointer(dict_t* x, const char* k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_cstring(dict_t* x, const char* k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_string (dict_t* x, const char* k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_cstring_array (dict_t* x, const char* k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_cstring_list (dict_t* x, const char* k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_cstring_map (dict_t* x, const char* k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_cstring_vset (dict_t* x, const char* k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_cstring_dict (dict_t* x, const char* k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_cstring_boolean(dict_t* x, const char* k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_int8 (dict_t* x, const char* k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_int16 (dict_t* x, const char* k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_int32 (dict_t* x, const char* k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_int64 (dict_t* x, const char* k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_uint8 (dict_t* x, const char* k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_uint16 (dict_t* x, const char* k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_uint32 (dict_t* x, const char* k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_uint64 (dict_t* x, const char* k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_float (dict_t* x, const char* k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_double (dict_t* x, const char* k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_cstring_ldouble(dict_t* x, const char* k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_string_pointer(dict_t* x, const str_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_cstring(dict_t* x, const str_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_string (dict_t* x, const str_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_string_array (dict_t* x, const str_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_string_list (dict_t* x, const str_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_string_map (dict_t* x, const str_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_string_vset (dict_t* x, const str_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_string_dict (dict_t* x, const str_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_string_boolean(dict_t* x, const str_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_int8 (dict_t* x, const str_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_int16 (dict_t* x, const str_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_int32 (dict_t* x, const str_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_int64 (dict_t* x, const str_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_uint8 (dict_t* x, const str_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_uint16 (dict_t* x, const str_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_uint32 (dict_t* x, const str_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_uint64 (dict_t* x, const str_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_float (dict_t* x, const str_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_double (dict_t* x, const str_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_string_ldouble(dict_t* x, const str_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_array_pointer(dict_t* x, const arr_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_cstring(dict_t* x, const arr_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_string (dict_t* x, const arr_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_array_array (dict_t* x, const arr_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_array_list (dict_t* x, const arr_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_array_map (dict_t* x, const arr_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_array_vset (dict_t* x, const arr_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_array_dict (dict_t* x, const arr_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_array_boolean(dict_t* x, const arr_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_int8 (dict_t* x, const arr_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_int16 (dict_t* x, const arr_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_int32 (dict_t* x, const arr_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_int64 (dict_t* x, const arr_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_uint8 (dict_t* x, const arr_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_uint16 (dict_t* x, const arr_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_uint32 (dict_t* x, const arr_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_uint64 (dict_t* x, const arr_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_float (dict_t* x, const arr_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_double (dict_t* x, const arr_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_array_ldouble(dict_t* x, const arr_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_list_pointer(dict_t* x, const list_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_cstring(dict_t* x, const list_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_string (dict_t* x, const list_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_list_array (dict_t* x, const list_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_list_list (dict_t* x, const list_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_list_map (dict_t* x, const list_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_list_vset (dict_t* x, const list_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_list_dict (dict_t* x, const list_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_list_boolean(dict_t* x, const list_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_int8 (dict_t* x, const list_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_int16 (dict_t* x, const list_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_int32 (dict_t* x, const list_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_int64 (dict_t* x, const list_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_uint8 (dict_t* x, const list_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_uint16 (dict_t* x, const list_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_uint32 (dict_t* x, const list_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_uint64 (dict_t* x, const list_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_float (dict_t* x, const list_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_double (dict_t* x, const list_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_list_ldouble(dict_t* x, const list_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_map_pointer(dict_t* x, const map_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_cstring(dict_t* x, const map_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_string (dict_t* x, const map_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_map_array (dict_t* x, const map_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_map_list (dict_t* x, const map_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_map_map (dict_t* x, const map_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_map_vset (dict_t* x, const map_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_map_dict (dict_t* x, const map_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_map_boolean(dict_t* x, const map_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_int8 (dict_t* x, const map_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_int16 (dict_t* x, const map_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_int32 (dict_t* x, const map_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_int64 (dict_t* x, const map_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_uint8 (dict_t* x, const map_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_uint16 (dict_t* x, const map_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_uint32 (dict_t* x, const map_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_uint64 (dict_t* x, const map_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_float (dict_t* x, const map_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_double (dict_t* x, const map_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_map_ldouble(dict_t* x, const map_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_vset_pointer(dict_t* x, const set_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_cstring(dict_t* x, const set_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_string (dict_t* x, const set_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_vset_array (dict_t* x, const set_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_vset_list (dict_t* x, const set_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_vset_map (dict_t* x, const set_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_vset_vset (dict_t* x, const set_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_vset_dict (dict_t* x, const set_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_vset_boolean(dict_t* x, const set_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_int8 (dict_t* x, const set_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_int16 (dict_t* x, const set_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_int32 (dict_t* x, const set_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_int64 (dict_t* x, const set_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_uint8 (dict_t* x, const set_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_uint16 (dict_t* x, const set_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_uint32 (dict_t* x, const set_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_uint64 (dict_t* x, const set_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_float (dict_t* x, const set_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_double (dict_t* x, const set_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_vset_ldouble(dict_t* x, const set_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_dict_pointer(dict_t* x, const dict_t* k, const void* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_cstring(dict_t* x, const dict_t* k, const char* v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_string (dict_t* x, const dict_t* k, const str_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_dict_array (dict_t* x, const dict_t* k, const arr_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_dict_list (dict_t* x, const dict_t* k, const list_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_dict_map (dict_t* x, const dict_t* k, const map_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_dict_vset (dict_t* x, const dict_t* k, const set_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_dict_dict (dict_t* x, const dict_t* k, const dict_t* v) { return libcdsb_dict_update(x, k, vtypeof(k), v, vtypeof( v)); } -bool libcdsb_dict_update_dict_boolean(dict_t* x, const dict_t* k, bool v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_int8 (dict_t* x, const dict_t* k, s8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_int16 (dict_t* x, const dict_t* k, s16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_int32 (dict_t* x, const dict_t* k, s32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_int64 (dict_t* x, const dict_t* k, s64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_uint8 (dict_t* x, const dict_t* k, u8_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_uint16 (dict_t* x, const dict_t* k, u16_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_uint32 (dict_t* x, const dict_t* k, u32_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_uint64 (dict_t* x, const dict_t* k, u64_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_float (dict_t* x, const dict_t* k, fl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_double (dict_t* x, const dict_t* k, dbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_dict_ldouble(dict_t* x, const dict_t* k, ldbl_t v) { return libcdsb_dict_update(x, k, vtypeof(k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_boolean_pointer(dict_t* x, bool k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_cstring(dict_t* x, bool k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_string (dict_t* x, bool k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_boolean_array (dict_t* x, bool k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_boolean_list (dict_t* x, bool k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_boolean_map (dict_t* x, bool k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_boolean_vset (dict_t* x, bool k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_boolean_dict (dict_t* x, bool k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_boolean_boolean(dict_t* x, bool k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_int8 (dict_t* x, bool k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_int16 (dict_t* x, bool k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_int32 (dict_t* x, bool k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_int64 (dict_t* x, bool k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_uint8 (dict_t* x, bool k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_uint16 (dict_t* x, bool k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_uint32 (dict_t* x, bool k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_uint64 (dict_t* x, bool k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_float (dict_t* x, bool k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_double (dict_t* x, bool k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_boolean_ldouble(dict_t* x, bool k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_uint8_pointer(dict_t* x, u8_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_cstring(dict_t* x, u8_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_string (dict_t* x, u8_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint8_array (dict_t* x, u8_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint8_list (dict_t* x, u8_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint8_map (dict_t* x, u8_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint8_vset (dict_t* x, u8_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint8_dict (dict_t* x, u8_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint8_boolean(dict_t* x, u8_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_int8 (dict_t* x, u8_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_int16 (dict_t* x, u8_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_int32 (dict_t* x, u8_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_int64 (dict_t* x, u8_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_uint8 (dict_t* x, u8_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_uint16 (dict_t* x, u8_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_uint32 (dict_t* x, u8_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_uint64 (dict_t* x, u8_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_float (dict_t* x, u8_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_double (dict_t* x, u8_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint8_ldouble(dict_t* x, u8_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_uint16_pointer(dict_t* x, u16_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_cstring(dict_t* x, u16_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_string (dict_t* x, u16_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint16_array (dict_t* x, u16_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint16_list (dict_t* x, u16_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint16_map (dict_t* x, u16_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint16_vset (dict_t* x, u16_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint16_dict (dict_t* x, u16_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint16_boolean(dict_t* x, u16_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_int8 (dict_t* x, u16_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_int16 (dict_t* x, u16_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_int32 (dict_t* x, u16_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_int64 (dict_t* x, u16_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_uint8 (dict_t* x, u16_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_uint16 (dict_t* x, u16_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_uint32 (dict_t* x, u16_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_uint64 (dict_t* x, u16_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_float (dict_t* x, u16_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_double (dict_t* x, u16_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint16_ldouble(dict_t* x, u16_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_uint32_pointer(dict_t* x, u32_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_cstring(dict_t* x, u32_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_string (dict_t* x, u32_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint32_array (dict_t* x, u32_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint32_list (dict_t* x, u32_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint32_map (dict_t* x, u32_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint32_vset (dict_t* x, u32_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint32_dict (dict_t* x, u32_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint32_boolean(dict_t* x, u32_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_int8 (dict_t* x, u32_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_int16 (dict_t* x, u32_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_int32 (dict_t* x, u32_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_int64 (dict_t* x, u32_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_uint8 (dict_t* x, u32_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_uint16 (dict_t* x, u32_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_uint32 (dict_t* x, u32_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_uint64 (dict_t* x, u32_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_float (dict_t* x, u32_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_double (dict_t* x, u32_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint32_ldouble(dict_t* x, u32_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_uint64_pointer(dict_t* x, u64_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_cstring(dict_t* x, u64_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_string (dict_t* x, u64_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint64_array (dict_t* x, u64_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint64_list (dict_t* x, u64_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint64_map (dict_t* x, u64_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint64_vset (dict_t* x, u64_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint64_dict (dict_t* x, u64_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_uint64_boolean(dict_t* x, u64_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_int8 (dict_t* x, u64_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_int16 (dict_t* x, u64_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_int32 (dict_t* x, u64_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_int64 (dict_t* x, u64_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_uint8 (dict_t* x, u64_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_uint16 (dict_t* x, u64_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_uint32 (dict_t* x, u64_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_uint64 (dict_t* x, u64_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_float (dict_t* x, u64_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_double (dict_t* x, u64_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_uint64_ldouble(dict_t* x, u64_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_int8_pointer(dict_t* x, s8_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_cstring(dict_t* x, s8_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_string (dict_t* x, s8_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int8_array (dict_t* x, s8_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int8_list (dict_t* x, s8_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int8_map (dict_t* x, s8_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int8_vset (dict_t* x, s8_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int8_dict (dict_t* x, s8_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int8_boolean(dict_t* x, s8_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_int8 (dict_t* x, s8_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_int16 (dict_t* x, s8_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_int32 (dict_t* x, s8_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_int64 (dict_t* x, s8_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_uint8 (dict_t* x, s8_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_uint16 (dict_t* x, s8_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_uint32 (dict_t* x, s8_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_uint64 (dict_t* x, s8_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_float (dict_t* x, s8_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_double (dict_t* x, s8_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int8_ldouble(dict_t* x, s8_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_int16_pointer(dict_t* x, s16_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_cstring(dict_t* x, s16_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_string (dict_t* x, s16_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int16_array (dict_t* x, s16_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int16_list (dict_t* x, s16_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int16_map (dict_t* x, s16_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int16_vset (dict_t* x, s16_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int16_dict (dict_t* x, s16_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int16_boolean(dict_t* x, s16_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_int8 (dict_t* x, s16_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_int16 (dict_t* x, s16_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_int32 (dict_t* x, s16_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_int64 (dict_t* x, s16_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_uint8 (dict_t* x, s16_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_uint16 (dict_t* x, s16_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_uint32 (dict_t* x, s16_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_uint64 (dict_t* x, s16_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_float (dict_t* x, s16_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_double (dict_t* x, s16_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int16_ldouble(dict_t* x, s16_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_int32_pointer(dict_t* x, s32_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_cstring(dict_t* x, s32_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_string (dict_t* x, s32_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int32_array (dict_t* x, s32_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int32_list (dict_t* x, s32_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int32_map (dict_t* x, s32_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int32_vset (dict_t* x, s32_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int32_dict (dict_t* x, s32_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int32_boolean(dict_t* x, s32_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_int8 (dict_t* x, s32_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_int16 (dict_t* x, s32_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_int32 (dict_t* x, s32_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_int64 (dict_t* x, s32_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_uint8 (dict_t* x, s32_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_uint16 (dict_t* x, s32_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_uint32 (dict_t* x, s32_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_uint64 (dict_t* x, s32_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_float (dict_t* x, s32_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_double (dict_t* x, s32_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int32_ldouble(dict_t* x, s32_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_int64_pointer(dict_t* x, s64_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_cstring(dict_t* x, s64_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_string (dict_t* x, s64_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int64_array (dict_t* x, s64_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int64_list (dict_t* x, s64_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int64_map (dict_t* x, s64_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int64_vset (dict_t* x, s64_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int64_dict (dict_t* x, s64_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_int64_boolean(dict_t* x, s64_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_int8 (dict_t* x, s64_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_int16 (dict_t* x, s64_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_int32 (dict_t* x, s64_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_int64 (dict_t* x, s64_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_uint8 (dict_t* x, s64_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_uint16 (dict_t* x, s64_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_uint32 (dict_t* x, s64_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_uint64 (dict_t* x, s64_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_float (dict_t* x, s64_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_double (dict_t* x, s64_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_int64_ldouble(dict_t* x, s64_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_float_pointer(dict_t* x, fl_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_cstring(dict_t* x, fl_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_string (dict_t* x, fl_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_float_array (dict_t* x, fl_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_float_list (dict_t* x, fl_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_float_map (dict_t* x, fl_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_float_vset (dict_t* x, fl_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_float_dict (dict_t* x, fl_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_float_boolean(dict_t* x, fl_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_int8 (dict_t* x, fl_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_int16 (dict_t* x, fl_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_int32 (dict_t* x, fl_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_int64 (dict_t* x, fl_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_uint8 (dict_t* x, fl_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_uint16 (dict_t* x, fl_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_uint32 (dict_t* x, fl_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_uint64 (dict_t* x, fl_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_float (dict_t* x, fl_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_double (dict_t* x, fl_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_float_ldouble(dict_t* x, fl_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_double_pointer(dict_t* x, dbl_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_cstring(dict_t* x, dbl_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_string (dict_t* x, dbl_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_double_array (dict_t* x, dbl_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_double_list (dict_t* x, dbl_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_double_map (dict_t* x, dbl_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_double_vset (dict_t* x, dbl_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_double_dict (dict_t* x, dbl_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_double_boolean(dict_t* x, dbl_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_int8 (dict_t* x, dbl_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_int16 (dict_t* x, dbl_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_int32 (dict_t* x, dbl_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_int64 (dict_t* x, dbl_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_uint8 (dict_t* x, dbl_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_uint16 (dict_t* x, dbl_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_uint32 (dict_t* x, dbl_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_uint64 (dict_t* x, dbl_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_float (dict_t* x, dbl_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_double (dict_t* x, dbl_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_double_ldouble(dict_t* x, dbl_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } - -bool libcdsb_dict_update_ldouble_pointer(dict_t* x, ldbl_t k, const void* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_cstring(dict_t* x, ldbl_t k, const char* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_string (dict_t* x, ldbl_t k, const str_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_ldouble_array (dict_t* x, ldbl_t k, const arr_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_ldouble_list (dict_t* x, ldbl_t k, const list_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_ldouble_map (dict_t* x, ldbl_t k, const map_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_ldouble_vset (dict_t* x, ldbl_t k, const set_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_ldouble_dict (dict_t* x, ldbl_t k, const dict_t* v) { return libcdsb_dict_update(x, &k, vtypeof(&k), v, vtypeof( v)); } -bool libcdsb_dict_update_ldouble_boolean(dict_t* x, ldbl_t k, bool v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_int8 (dict_t* x, ldbl_t k, s8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_int16 (dict_t* x, ldbl_t k, s16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_int32 (dict_t* x, ldbl_t k, s32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_int64 (dict_t* x, ldbl_t k, s64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_uint8 (dict_t* x, ldbl_t k, u8_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_uint16 (dict_t* x, ldbl_t k, u16_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_uint32 (dict_t* x, ldbl_t k, u32_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_uint64 (dict_t* x, ldbl_t k, u64_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_float (dict_t* x, ldbl_t k, fl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_double (dict_t* x, ldbl_t k, dbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } -bool libcdsb_dict_update_ldouble_ldouble(dict_t* x, ldbl_t k, ldbl_t v) { return libcdsb_dict_update(x, &k, vtypeof(&k), &v, vtypeof(&v)); } diff --git a/src/dict/include.h b/src/dict/include.h index dc726d1..d0cfd6a 100644 --- a/src/dict/include.h +++ b/src/dict/include.h @@ -1,7 +1,7 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ -#include "../../include/extra/dict.h" +#include "../../include/dict.h" #include "../__internal/assert.h" #include "../__internal/rbtree.h" diff --git a/src/dict/memory.c b/src/dict/memory.c new file mode 100644 index 0000000..4b2a5b2 --- /dev/null +++ b/src/dict/memory.c @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "include.h" + +void dict_init(dict_t* x) { + memset(x, 0, sizeof(*x)); +} + +void dict_free(dict_t* x) { + + while (x->capacity--) { + while (!is_null(x->nodes[x->capacity])) { + vnode_free(&x->nodes[x->capacity]->key, x->nodes[x->capacity]->key_type); + vnode_free(&x->nodes[x->capacity]->value, x->nodes[x->capacity]->value_type); + + x->nodes[x->capacity] = x->nodes[x->capacity]->prev; + } + } + + free(x->nodes); + memset(x, 0, sizeof(*x)); +} diff --git a/src/dict/modify.c b/src/dict/modify.c new file mode 100644 index 0000000..33f6a84 --- /dev/null +++ b/src/dict/modify.c @@ -0,0 +1,189 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../include/list.h" +#include "include.h" + +static void dict_rehash(dict_t* s, size_t capacity) { + dnode_t **nodes, *c, *n, **p; + size_t i; + + i = s->capacity; + nodes = calloc(sizeof(*nodes), capacity); + + while (i--) { + c = s->nodes[i]; + + while (!is_null(c)) { + p = nodes + (vnode_hash(&c->key, c->key_type) % capacity); + n = c->prev; + c->prev = *p; + + *p = c; + c = n; + } + } + + free(s->nodes); + s->nodes = nodes; + s->capacity = capacity; +} + +/*#####################################################################################################################*/ + +bool libcdsb_dict_shrink_to_fit(dict_t* s) { + + size_t capacity; + + capacity = (s->size / CAPACITY_BLOCK) + 1; + capacity *= CAPACITY_BLOCK; + + while (((double)s->size / capacity) > 0.65) + capacity += CAPACITY_BLOCK; + + if (capacity >= s->capacity) + return false; + + dict_rehash(s, capacity); + + return true; +} + + +bool libcdsb_dict_update(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { + dnode_t *c, **p; + + if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) + dict_rehash(x, x->capacity + CAPACITY_BLOCK); + + c = *(p = x->nodes + (vtype_hash(k, kt) % x->capacity)); + + while (!is_null(c)) { + if (vtype_compare(k, kt, vnode_peek(&c->key, c->key_type), c->key_type) == 0) { + vnode_free(&c->value, c->value_type); + + c->value = vnode_create(v, vt); + c->value_type = vt; + + return true; + } else c = c->prev; + } + + c = malloc(sizeof(*c)); + + c->prev = *p; + c->key = vnode_create(k, kt); + c->value = vnode_create(v, vt); + c->key_type = kt; + c->value_type = vt; + + *p = c; + ++x->size; + + return false; +} + + +bool libcdsb_dict_inject(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { + dnode_t *c, **p; + + if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) + dict_rehash(x, x->capacity + CAPACITY_BLOCK); + + c = *(p = x->nodes + (vtype_hash(k, kt) % x->capacity)); + + while (!is_null(c)) { + if (vtype_compare(k, kt, vnode_peek(&c->key, c->key_type), c->key_type) == 0) { + vnode_free(&c->value, c->value_type); + + c->value = vnode_create(v, vt); + c->value_type = vt; + + return true; + } else c = c->prev; + } + + c = malloc(sizeof(*c)); + + c->prev = *p; + c->key_type = kt; + c->value_type = vt; + + vnode_attach(&c->key, k, kt); + vnode_attach(&c->value, v, vt); + + *p = c; + ++x->size; + + return false; +} + + +bool libcdsb_dict_inject_key(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { + dnode_t *c, **p; + + if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) + dict_rehash(x, x->capacity + CAPACITY_BLOCK); + + c = *(p = x->nodes + (vtype_hash(k, kt) % x->capacity)); + + while (!is_null(c)) { + if (vtype_compare(k, kt, vnode_peek(&c->key, c->key_type), c->key_type) == 0) { + vnode_free(&c->value, c->value_type); + + c->value = vnode_create(v, vt); + c->value_type = vt; + + return true; + } else c = c->prev; + } + + c = malloc(sizeof(*c)); + + c->prev = *p; + c->value = vnode_create(v, vt); + c->key_type = kt; + c->value_type = vt; + + vnode_attach(&c->key, k, kt); + + *p = c; + ++x->size; + + return false; +} + + +bool libcdsb_dict_inject_value(dict_t* x, const void* k, vtype kt, const void* v, vtype vt) { + dnode_t *c, **p; + + if (!x->capacity || (double)x->size / x->capacity > REBUILD_POINT_MAX) + dict_rehash(x, x->capacity + CAPACITY_BLOCK); + + c = *(p = x->nodes + (vtype_hash(k, kt) % x->capacity)); + + while (!is_null(c)) { + if (vtype_compare(k, kt, vnode_peek(&c->key, c->key_type), c->key_type) == 0) { + vnode_free(&c->value, c->value_type); + + c->value = vnode_create(v, vt); + c->value_type = vt; + + return true; + } else c = c->prev; + } + + c = malloc(sizeof(*c)); + + c->prev = *p; + c->key = vnode_create(k, kt); + c->key_type = kt; + c->value_type = vt; + + vnode_attach(&c->value, v, vt); + + *p = c; + ++x->size; + + return false; +} diff --git a/tests/src/dict/plug.h b/tests/src/dict/plug.h index e6b73db..e3ffb5f 100644 --- a/tests/src/dict/plug.h +++ b/tests/src/dict/plug.h @@ -1,7 +1,7 @@ /* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ -#include "../../../include/extra/dict.h" +#include "../../../include/dict.h" #include "../../include/random.h" #include "../../include/test.h" diff --git a/tests/src/global/plug.h b/tests/src/global/plug.h index f9409d8..b2dce62 100644 --- a/tests/src/global/plug.h +++ b/tests/src/global/plug.h @@ -6,7 +6,7 @@ #include "../../../include/list.h" #include "../../../include/set.h" #include "../../../include/map.h" -#include "../../../include/extra/dict.h" +#include "../../../include/dict.h" #include "../../include/random.h" #include "../../include/test.h"