![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
Include dependency graph for genhash.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | genhash_keys_iterate(ARG_ht, NAME_key) |
| #define | genhash_keys_iterate_end generic_iterate_end |
| #define | genhash_values_iterate(ARG_ht, NAME_value) |
| #define | genhash_values_iterate_end generic_iterate_end |
| #define | genhash_iterate(ARG_ht, NAME_iter) |
| #define | genhash_iterate_end generic_iterate_end |
Typedefs | |
| typedef unsigned int | genhash_val_t |
| typedef genhash_val_t(* | genhash_val_fn_t) (const void *) |
| typedef bool(* | genhash_comp_fn_t) (const void *, const void *) |
| typedef void *(* | genhash_copy_fn_t) (const void *) |
| typedef void(* | genhash_free_fn_t) (void *) |
Functions | |
| genhash_val_t | genhash_str_val_func (const char *vkey) |
| A supplied genhash function appropriate to nul-terminated strings. More... | |
| bool | genhash_str_comp_func (const char *vkey1, const char *vkey2) |
| A supplied function for comparison of nul-terminated strings: More... | |
| char * | genhash_str_copy_func (const char *vkey) |
| Copy function for string allocation. More... | |
| void | genhash_str_free_func (char *vkey) |
| Free function for string allocation. More... | |
| struct genhash * | genhash_new (genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func) fc__warn_unused_result |
| Constructor with unspecified number of entries. More... | |
| 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) fc__warn_unused_result |
| Constructor with unspecified number of entries. More... | |
| struct genhash * | genhash_new_nentries (genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, size_t nentries) fc__warn_unused_result |
| Constructor specifying number of entries. More... | |
| 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) fc__warn_unused_result |
| Constructor specifying number of entries. More... | |
| void | genhash_destroy (struct genhash *pgenhash) |
| Destructor: free internal memory. More... | |
| bool | genhash_set_no_shrink (struct genhash *pgenhash, bool no_shrink) |
| Prevent or allow the genhash table automatically shrinking. More... | |
| size_t | genhash_size (const struct genhash *pgenhash) |
| Returns the number of entries in the genhash table. More... | |
| size_t | genhash_capacity (const struct genhash *pgenhash) |
| Returns the number of buckets in the genhash table. More... | |
| struct genhash * | genhash_copy (const struct genhash *pgenhash) fc__warn_unused_result |
| Returns a newly allocated mostly deep copy of the given genhash table. More... | |
| void | genhash_clear (struct genhash *pgenhash) |
| Remove all entries of the genhash table. More... | |
| bool | genhash_insert (struct genhash *pgenhash, const void *key, const void *data) |
| Insert entry: returns TRUE if inserted, or FALSE if there was already an entry with the same key, in which case the entry was not inserted. More... | |
| bool | genhash_replace (struct genhash *pgenhash, const void *key, const void *data) |
| Insert entry, replacing any existing entry which has the same key. More... | |
| bool | genhash_replace_full (struct genhash *pgenhash, const void *key, const void *data, void **old_pkey, void **old_pdata) |
| Insert entry, replacing any existing entry which has the same key. More... | |
| bool | genhash_lookup (const struct genhash *pgenhash, const void *key, void **pdata) |
| Lookup data. More... | |
| bool | genhash_remove (struct genhash *pgenhash, const void *key) |
| Delete an entry from the genhash table. More... | |
| bool | genhash_remove_full (struct genhash *pgenhash, const void *key, void **deleted_pkey, void **deleted_pdata) |
| Delete an entry from the genhash table. More... | |
| bool | genhashs_are_equal (const struct genhash *pgenhash1, const struct genhash *pgenhash2) |
| Returns TRUE iff the hash tables contains the same pairs of key/data. More... | |
| bool | genhashs_are_equal_full (const struct genhash *pgenhash1, const struct genhash *pgenhash2, genhash_comp_fn_t data_comp_func) |
| Returns TRUE iff the hash tables contains the same pairs of key/data. More... | |
| size_t | genhash_iter_sizeof () |
| "Sizeof" function implementation for generic_iterate genhash iterators. More... | |
| struct iterator * | genhash_key_iter_init (struct genhash_iter *iter, const struct genhash *hash) |
| Returns an iterator over the genhash table's k genhashgenhashenhashys. More... | |
| struct iterator * | genhash_value_iter_init (struct genhash_iter *iter, const struct genhash *hash) |
| Returns an iterator over the hash table's values. More... | |
| struct iterator * | genhash_iter_init (struct genhash_iter *iter, const struct genhash *hash) |
| Returns an iterator that iterates over both keys and values of the genhash table. More... | |
| void * | genhash_iter_key (const struct iterator *genhash_iter) |
| Helper function for genhash (key, value) pair iteration. More... | |
| void * | genhash_iter_value (const struct iterator *genhash_iter) |
| Helper function for genhash (key, value) pair iteration. More... | |
| #define genhash_iterate | ( | ARG_ht, | |
| NAME_iter | |||
| ) |
| #define genhash_iterate_end generic_iterate_end |
| #define genhash_keys_iterate | ( | ARG_ht, | |
| NAME_key | |||
| ) |
| #define genhash_keys_iterate_end generic_iterate_end |
| #define genhash_values_iterate | ( | ARG_ht, | |
| NAME_value | |||
| ) |
| #define genhash_values_iterate_end generic_iterate_end |
| typedef bool(* genhash_comp_fn_t) (const void *, const void *) |
| typedef genhash_val_t(* genhash_val_fn_t) (const void *) |
| typedef unsigned int genhash_val_t |
| size_t genhash_capacity | ( | const struct genhash * | pgenhash | ) |
Returns the number of buckets in the genhash table.
Definition at line 528 of file genhash.cpp.
| void genhash_clear | ( | struct genhash * | pgenhash | ) |
Remove all entries of the genhash table.
Definition at line 575 of file genhash.cpp.
Referenced by conn_reset_delta_state(), and genhash_destroy().
Returns a newly allocated mostly deep copy of the given genhash table.
Definition at line 537 of file genhash.cpp.
| void genhash_destroy | ( | struct genhash * | pgenhash | ) |
Destructor: free internal memory.
Definition at line 284 of file genhash.cpp.
Referenced by free_packet_hashes().
| bool genhash_insert | ( | struct genhash * | pgenhash, |
| const void * | key, | ||
| const void * | data | ||
| ) |
Insert entry: returns TRUE if inserted, or FALSE if there was already an entry with the same key, in which case the entry was not inserted.
Definition at line 597 of file genhash.cpp.
| struct iterator* genhash_iter_init | ( | struct genhash_iter * | iter, |
| const struct genhash * | pgenhash | ||
| ) |
Returns an iterator that iterates over both keys and values of the genhash table.
NB: iterator_get() returns an iterator pointer, so use the helper functions genhash_iter_get_{key,value} to access the key and value.
Definition at line 880 of file genhash.cpp.
| void* genhash_iter_key | ( | const struct iterator * | genhash_iter | ) |
Helper function for genhash (key, value) pair iteration.
Definition at line 792 of file genhash.cpp.
Referenced by genhash_key_iter_init().
| size_t genhash_iter_sizeof | ( | ) |
"Sizeof" function implementation for generic_iterate genhash iterators.
Definition at line 787 of file genhash.cpp.
| void* genhash_iter_value | ( | const struct iterator * | genhash_iter | ) |
Helper function for genhash (key, value) pair iteration.
Definition at line 801 of file genhash.cpp.
Referenced by genhash_value_iter_init().
| struct iterator* genhash_key_iter_init | ( | struct genhash_iter * | iter, |
| const struct genhash * | hash | ||
| ) |
Returns an iterator over the genhash table's k genhashgenhashenhashys.
Definition at line 889 of file genhash.cpp.
| bool genhash_lookup | ( | const struct genhash * | pgenhash, |
| const void * | key, | ||
| void ** | pdata | ||
| ) |
Lookup data.
Return TRUE on success, then pdata - if not nullptr will be set to the data value.
Definition at line 675 of file genhash.cpp.
| struct genhash* genhash_new | ( | genhash_val_fn_t | key_val_func, |
| genhash_comp_fn_t | key_comp_func | ||
| ) |
Constructor with unspecified number of entries.
Definition at line 274 of file genhash.cpp.
| 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 | ||
| ) |
Constructor with unspecified number of entries.
Allows to specify functions to free the memory allocated for the key and user-data that get called when removing the bucket from the hash table or changing key/user-data values.
Definition at line 259 of file genhash.cpp.
| struct genhash* genhash_new_nentries | ( | genhash_val_fn_t | key_val_func, |
| genhash_comp_fn_t | key_comp_func, | ||
| size_t | nentries | ||
| ) |
Constructor specifying number of entries.
Definition at line 244 of file genhash.cpp.
| 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 | ||
| ) |
Constructor specifying number of entries.
Allows to specify functions to free the memory allocated for the key and user-data that get called when removing the bucket from the hash table or changing key/user-data values.
Definition at line 228 of file genhash.cpp.
| bool genhash_remove | ( | struct genhash * | pgenhash, |
| const void * | key | ||
| ) |
Delete an entry from the genhash table.
Returns TRUE on success.
Definition at line 696 of file genhash.cpp.
| bool genhash_remove_full | ( | struct genhash * | pgenhash, |
| const void * | key, | ||
| void ** | deleted_pkey, | ||
| void ** | deleted_pdata | ||
| ) |
Delete an entry from the genhash table.
Returns TRUE on success.
Returns in 'deleted_pkey' and 'deleted_pdata' the old contents of the deleted entry if not nullptr. NB: It can returns freed pointers if free functions were supplied to the genhash table.
Definition at line 708 of file genhash.cpp.
Referenced by genhash_remove().
| bool genhash_replace | ( | struct genhash * | pgenhash, |
| const void * | key, | ||
| const void * | data | ||
| ) |
Insert entry, replacing any existing entry which has the same key.
Returns TRUE if a data have been replaced, FALSE if it was a simple insertion.
Definition at line 625 of file genhash.cpp.
| bool genhash_replace_full | ( | struct genhash * | pgenhash, |
| const void * | key, | ||
| const void * | data, | ||
| void ** | old_pkey, | ||
| void ** | old_pdata | ||
| ) |
Insert entry, replacing any existing entry which has the same key.
Returns TRUE if a data have been replaced, FALSE if it was a simple insertion.
Returns in 'old_pkey' and 'old_pdata' the old content of the bucket if they are not nullptr. NB: It can returns freed pointers if free functions were supplied to the genhash table.
Definition at line 640 of file genhash.cpp.
Referenced by genhash_replace().
| bool genhash_set_no_shrink | ( | struct genhash * | pgenhash, |
| bool | no_shrink | ||
| ) |
Prevent or allow the genhash table automatically shrinking.
Returns the old value of the setting.
Definition at line 506 of file genhash.cpp.
| size_t genhash_size | ( | const struct genhash * | pgenhash | ) |
Returns the number of entries in the genhash table.
Definition at line 519 of file genhash.cpp.
| bool genhash_str_comp_func | ( | const char * | vkey1, |
| const char * | vkey2 | ||
| ) |
A supplied function for comparison of nul-terminated strings:
Definition at line 119 of file genhash.cpp.
| char* genhash_str_copy_func | ( | const char * | vkey | ) |
Copy function for string allocation.
Definition at line 127 of file genhash.cpp.
| void genhash_str_free_func | ( | char * | vkey | ) |
Free function for string allocation.
Definition at line 135 of file genhash.cpp.
| genhash_val_t genhash_str_val_func | ( | const char * | vkey | ) |
A supplied genhash function appropriate to nul-terminated strings.
Prefers table sizes that are prime numbers.
Definition at line 104 of file genhash.cpp.
| struct iterator* genhash_value_iter_init | ( | struct genhash_iter * | iter, |
| const struct genhash * | hash | ||
| ) |
Returns an iterator over the hash table's values.
Definition at line 898 of file genhash.cpp.
Returns TRUE iff the hash tables contains the same pairs of key/data.
Definition at line 734 of file genhash.cpp.
| bool genhashs_are_equal_full | ( | const struct genhash * | pgenhash1, |
| const struct genhash * | pgenhash2, | ||
| genhash_comp_fn_t | data_comp_func | ||
| ) |
Returns TRUE iff the hash tables contains the same pairs of key/data.
Definition at line 743 of file genhash.cpp.
Referenced by genhashs_are_equal().