153#ifdef SPECHASH_INT_KEY_TYPE
154#undef SPECHASH_INT_KEY_TYPE
155#define SPECHASH_UKEY_TYPE int
156#define SPECHASH_IKEY_TYPE void *
157#define SPECHASH_IKEY_TO_UKEY FC_PTR_TO_INT
158#define SPECHASH_UKEY_TO_IKEY FC_INT_TO_PTR
159#define SPECHASH_IKEY_VAL nullptr
160#define SPECHASH_IKEY_COMP nullptr
161#define SPECHASH_IKEY_COPY nullptr
162#define SPECHASH_IKEY_FREE nullptr
164#ifdef SPECHASH_INT_DATA_TYPE
165#undef SPECHASH_INT_DATA_TYPE
166#define SPECHASH_UDATA_TYPE int
167#define SPECHASH_IDATA_TYPE void *
168#define SPECHASH_IDATA_TO_UDATA FC_PTR_TO_INT
169#define SPECHASH_UDATA_TO_IDATA FC_INT_TO_PTR
170#define SPECHASH_IDATA_COMP nullptr
171#define SPECHASH_IDATA_COPY nullptr
172#define SPECHASH_IDATA_FREE nullptr
174#ifdef SPECHASH_ENUM_KEY_TYPE
175#define SPECHASH_UKEY_TYPE enum SPECHASH_ENUM_KEY_TYPE
176#define SPECHASH_IKEY_TYPE void *
177#define SPECHASH_IKEY_TO_UKEY FC_PTR_TO_INT
178#define SPECHASH_UKEY_TO_IKEY FC_INT_TO_PTR
179#define SPECHASH_IKEY_VAL nullptr
180#define SPECHASH_IKEY_COMP nullptr
181#define SPECHASH_IKEY_COPY nullptr
182#define SPECHASH_IKEY_FREE nullptr
184#ifdef SPECHASH_ENUM_DATA_TYPE
185#define SPECHASH_UDATA_TYPE enum SPECHASH_ENUM_DATA_TYPE
186#define SPECHASH_IDATA_TYPE void *
187#define SPECHASH_IDATA_TO_UDATA FC_PTR_TO_INT
188#define SPECHASH_UDATA_TO_IDATA FC_INT_TO_PTR
189#define SPECHASH_IDATA_COMP nullptr
190#define SPECHASH_IDATA_COPY nullptr
191#define SPECHASH_IDATA_FREE nullptr
193#ifdef SPECHASH_ASTR_KEY_TYPE
194#undef SPECHASH_ASTR_KEY_TYPE
195#define SPECHASH_IKEY_TYPE char *
196#define SPECHASH_IKEY_VAL genhash_str_val_func
197#define SPECHASH_IKEY_COMP genhash_str_comp_func
198#define SPECHASH_IKEY_COPY genhash_str_copy_func
199#define SPECHASH_IKEY_FREE genhash_str_free_func
201#ifdef SPECHASH_ASTR_DATA_TYPE
202#undef SPECHASH_ASTR_DATA_TYPE
203#define SPECHASH_IDATA_TYPE char *
204#define SPECHASH_IDATA_COMP genhash_str_comp_func
205#define SPECHASH_IDATA_COPY genhash_str_copy_func
206#define SPECHASH_IDATA_FREE genhash_str_free_func
208#ifdef SPECHASH_CSTR_KEY_TYPE
209#undef SPECHASH_CSTR_KEY_TYPE
210#define SPECHASH_IKEY_TYPE char *
211#define SPECHASH_IKEY_VAL genhash_str_val_func
212#define SPECHASH_IKEY_COMP genhash_str_comp_func
213#define SPECHASH_IKEY_COPY nullptr
214#define SPECHASH_IKEY_FREE nullptr
216#ifdef SPECHASH_CSTR_DATA_TYPE
217#undef SPECHASH_CSTR_DATA_TYPE
218#define SPECHASH_IDATA_TYPE char *
219#define SPECHASH_IDATA_COMP genhash_str_comp_func
220#define SPECHASH_IDATA_COPY nullptr
221#define SPECHASH_IDATA_FREE nullptr
224#ifndef SPECHASH_VPTR_TO_IKEY
225#define SPECHASH_VPTR_TO_IKEY(p) ((SPECHASH_IKEY_TYPE)(p))
228#ifndef SPECHASH_VPTR_TO_IDATA
229#define SPECHASH_VPTR_TO_IDATA(p) ((SPECHASH_IDATA_TYPE)(p))
233#error Must define a SPECHASH_TAG to use this header
235#ifndef SPECHASH_IKEY_TYPE
236#error Must define a SPECHASH_IKEY_TYPE to use this header
238#ifndef SPECHASH_UKEY_TYPE
239#define SPECHASH_UKEY_TYPE SPECHASH_IKEY_TYPE
241#ifndef SPECHASH_IDATA_TYPE
242#error Must define a SPECHASH_IDATA_TYPE to use this header
244#ifndef SPECHASH_UDATA_TYPE
245#define SPECHASH_UDATA_TYPE SPECHASH_IDATA_TYPE
249#ifndef SPECHASH_IKEY_VAL
250#define SPECHASH_IKEY_VAL nullptr
252#ifndef SPECHASH_IKEY_COMP
253#define SPECHASH_IKEY_COMP nullptr
255#ifndef SPECHASH_IKEY_COPY
256#define SPECHASH_IKEY_COPY nullptr
258#ifndef SPECHASH_IKEY_FREE
259#define SPECHASH_IKEY_FREE nullptr
261#ifndef SPECHASH_IDATA_COMP
262#define SPECHASH_IDATA_COMP nullptr
264#ifndef SPECHASH_IDATA_COPY
265#define SPECHASH_IDATA_COPY nullptr
267#ifndef SPECHASH_IDATA_FREE
268#define SPECHASH_IDATA_FREE nullptr
272#ifndef SPECHASH_UKEY_TO_IKEY
273#define SPECHASH_UKEY_TO_IKEY(ukey) ((SPECHASH_IKEY_TYPE) (ukey))
275#ifndef SPECHASH_IKEY_TO_UKEY
276#define SPECHASH_IKEY_TO_UKEY(ikey) ((SPECHASH_UKEY_TYPE) (ikey))
278#ifndef SPECHASH_UDATA_TO_IDATA
279#define SPECHASH_UDATA_TO_IDATA(udata) ((SPECHASH_IDATA_TYPE) (udata))
281#ifndef SPECHASH_IDATA_TO_UDATA
282#define SPECHASH_IDATA_TO_UDATA(idata) ((SPECHASH_UDATA_TYPE) (idata))
285#define SPECHASH_PASTE_(x, y) x ## y
286#define SPECHASH_PASTE(x, y) SPECHASH_PASTE_(x, y)
288#define SPECHASH_HASH struct SPECHASH_PASTE(SPECHASH_TAG, _hash)
289#define SPECHASH_ITER struct SPECHASH_PASTE(SPECHASH_TAG, _hash_iter)
290#define SPECHASH_FOO(suffix) SPECHASH_PASTE(SPECHASH_TAG, suffix)
657#undef SPECHASH_IKEY_TYPE
658#undef SPECHASH_UKEY_TYPE
659#undef SPECHASH_IDATA_TYPE
660#undef SPECHASH_UDATA_TYPE
661#undef SPECHASH_IKEY_VAL
662#undef SPECHASH_IKEY_COMP
663#undef SPECHASH_IKEY_COPY
664#undef SPECHASH_IKEY_FREE
665#undef SPECHASH_IDATA_COMP
666#undef SPECHASH_IDATA_COPY
667#undef SPECHASH_IDATA_FREE
668#undef SPECHASH_UKEY_TO_IKEY
669#undef SPECHASH_IKEY_TO_UKEY
670#undef SPECHASH_UDATA_TO_IDATA
671#undef SPECHASH_IDATA_TO_UDATA
672#undef SPECHASH_VPTR_TO_IKEY
673#undef SPECHASH_VPTR_TO_IDATA
674#undef SPECHASH_PASTE_
679#ifdef SPECHASH_ENUM_KEY_TYPE
680#undef SPECHASH_ENUM_KEY_TYPE
682#ifdef SPECHASH_ENUM_DATA_TYPE
683#undef SPECHASH_ENUM_DATA_TYPE
688#ifndef FC__SPECHASH_H
689#define FC__SPECHASH_H
696#define TYPED_HASH_DATA_ITERATE(TYPE_data, ARG_ht, NAME_data) \
697 generic_iterate(struct genhash_iter, TYPE_data, NAME_data, \
698 genhash_iter_sizeof, genhash_value_iter_init, \
699 (const struct genhash *) (ARG_ht))
702#define HASH_DATA_ITERATE_END generic_iterate_end
709#define TYPED_HASH_KEYS_ITERATE(TYPE_key, ARG_ht, NAME_key) \
710 generic_iterate(struct genhash_iter, TYPE_key, NAME_key, \
711 genhash_iter_sizeof, genhash_key_iter_init, \
712 (const struct genhash *) (ARG_ht))
715#define HASH_KEYS_ITERATE_END \
726#define TYPED_HASH_ITERATE(TYPE_key, TYPE_data, ARG_ht, NAME_key, NAME_data)\
727 genhash_iterate((const struct genhash *) (ARG_ht), MY_iter) { \
728 TYPE_key NAME_key = (TYPE_key) genhash_iter_key(MY_iter); \
729 TYPE_data NAME_data = (TYPE_data) genhash_iter_value(MY_iter);
732#define HASH_ITERATE_END \
733 } genhash_iterate_end;
struct iterator * genhash_iter_init(struct genhash_iter *iter, const struct genhash *pgenhash)
struct genhash * genhash_new_full(genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, genhash_copy_fn_t key_copy_func, genhash_free_fn_t key_free_func, genhash_copy_fn_t data_copy_func, genhash_free_fn_t data_free_func)
bool genhash_insert(struct genhash *pgenhash, const void *key, const void *data)
bool genhash_set_no_shrink(struct genhash *pgenhash, bool no_shrink)
size_t genhash_size(const struct genhash *pgenhash)
void genhash_destroy(struct genhash *pgenhash)
size_t genhash_capacity(const struct genhash *pgenhash)
void genhash_clear(struct genhash *pgenhash)
struct iterator * genhash_value_iter_init(struct genhash_iter *iter, const struct genhash *pgenhash)
size_t genhash_iter_sizeof(void)
bool genhash_lookup(const struct genhash *pgenhash, const void *key, void **pdata)
bool genhashes_are_equal_full(const struct genhash *pgenhash1, const struct genhash *pgenhash2, genhash_comp_fn_t data_comp_func)
bool genhash_remove(struct genhash *pgenhash, const void *key)
bool genhash_replace_full(struct genhash *pgenhash, const void *key, const void *data, void **old_pkey, void **old_pdata)
struct iterator * genhash_key_iter_init(struct genhash_iter *iter, const struct genhash *pgenhash)
bool genhash_replace(struct genhash *pgenhash, const void *key, const void *data)
struct genhash * genhash_copy(const struct genhash *pgenhash)
struct genhash * genhash_new_nentries_full(genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, genhash_copy_fn_t key_copy_func, genhash_free_fn_t key_free_func, genhash_copy_fn_t data_copy_func, genhash_free_fn_t data_free_func, size_t nentries)
bool genhash_remove_full(struct genhash *pgenhash, const void *key, void **deleted_pkey, void **deleted_pdata)
genhash_val_t(* genhash_val_fn_t)(const void *)
bool(* genhash_comp_fn_t)(const void *, const void *)
void(* genhash_free_fn_t)(void *)
void *(* genhash_copy_fn_t)(const void *)
unsigned int genhash_val_t
#define SPECHASH_IKEY_TYPE
#define SPECHASH_IDATA_TYPE
#define SPECHASH_IDATA_FREE
static bool SPECHASH_FOO() _hash_remove_full(SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, SPECHASH_UKEY_TYPE *deleted_pukey, SPECHASH_UDATA_TYPE *deleted_pudata)
static size_t SPECHASH_FOO() _hash_capacity(const SPECHASH_HASH *tthis)
#define SPECHASH_IDATA_TO_UDATA(idata)
#define SPECHASH_UDATA_TYPE
#define SPECHASH_FOO(suffix)
#define SPECHASH_IDATA_COPY
static bool SPECHASH_FOO() _hash_lookup(const SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, SPECHASH_UDATA_TYPE *pudata)
static size_t SPECHASH_FOO() _hash_size(const SPECHASH_HASH *tthis)
static bool SPECHASH_FOO() _hash_insert(SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, const SPECHASH_UDATA_TYPE udata)
#define SPECHASH_IKEY_FREE
static SPECHASH_HASH *SPECHASH_FOO() _hash_new_nentries_full(SPECHASH_FOO(_hash_key_val_fn_t) key_val_func, key_comp_func, key_copy_func, key_free_func, data_copy_func, data_free_func, size_t nentries) fc__warn_unused_result
static bool SPECHASH_FOO() _hash_replace(SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, const SPECHASH_UDATA_TYPE udata)
#define SPECHASH_IKEY_VAL
#define SPECHASH_IKEY_COMP
static void SPECHASH_FOO() _hash_destroy(SPECHASH_HASH *tthis)
static bool SPECHASH_FOO() _hashes_are_equal_full(const SPECHASH_HASH *phash1, const SPECHASH_HASH *phash2, data_comp_func)
#define SPECHASH_UDATA_TO_IDATA(udata)
static bool SPECHASH_FOO() _hashes_are_equal(const SPECHASH_HASH *phash1, const SPECHASH_HASH *phash2)
static SPECHASH_HASH *SPECHASH_FOO() _hash_new_full(SPECHASH_FOO(_hash_key_val_fn_t) key_val_func, key_comp_func, key_copy_func, key_free_func, data_copy_func, data_free_func) fc__warn_unused_result
static struct iterator *SPECHASH_FOO() _hash_iter_init(SPECHASH_ITER *iter, const SPECHASH_HASH *tthis)
#define SPECHASH_IDATA_COMP
static bool SPECHASH_FOO() _hash_remove(SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey)
#define SPECHASH_UKEY_TYPE
static struct iterator *SPECHASH_FOO() _hash_value_iter_init(SPECHASH_ITER *iter, const SPECHASH_HASH *tthis)
static bool SPECHASH_FOO() _hash_replace_full(SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, const SPECHASH_UDATA_TYPE udata, SPECHASH_UKEY_TYPE *old_pukey, SPECHASH_UDATA_TYPE *old_pudata)
static void SPECHASH_FOO() _hash_clear(SPECHASH_HASH *tthis)
static size_t SPECHASH_FOO() _hash_iter_sizeof(void)
static SPECHASH_HASH *SPECHASH_FOO() _hash_new_nentries(size_t nentries) fc__warn_unused_result
static struct iterator *SPECHASH_FOO() _hash_key_iter_init(SPECHASH_ITER *iter, const SPECHASH_HASH *tthis)
static bool SPECHASH_FOO() _hash_set_no_shrink(SPECHASH_HASH *tthis, bool no_shrink)
#define SPECHASH_VPTR_TO_IKEY(p)
#define SPECHASH_IKEY_COPY
#define SPECHASH_VPTR_TO_IDATA(p)
#define SPECHASH_UKEY_TO_IKEY(ukey)
static SPECHASH_HASH *SPECHASH_FOO() _hash_copy(const SPECHASH_HASH *tthis) fc__warn_unused_result
#define SPECHASH_IKEY_TO_UKEY(ikey)
static SPECHASH_HASH *SPECHASH_FOO() _hash_new(void) fc__warn_unused_result
#define fc__warn_unused_result