46 #ifndef HG_HASH_TABLE_H
47 #define HG_HASH_TABLE_H
49 #include "mercury_util_config.h"
99 #define HG_HASH_TABLE_NULL ((void *) 0)
183 hg_hash_table_key_t key,
184 hg_hash_table_value_t value);
194 HG_UTIL_EXPORT hg_hash_table_value_t
196 hg_hash_table_key_t key);
215 HG_UTIL_EXPORT
unsigned int
248 HG_UTIL_EXPORT hg_hash_table_value_t
hg_hash_table_entry_t * next_entry
void * hg_hash_table_value_t
A value stored in a hg_hash_table_t.
void(* hg_hash_table_value_free_func_t)(hg_hash_table_value_t value)
Type of function used to free values when entries are removed from a hash table.
HG_UTIL_EXPORT hg_hash_table_value_t hg_hash_table_lookup(hg_hash_table_t *hash_table, hg_hash_table_key_t key)
Look up a value in a hash table by key.
unsigned int(* hg_hash_table_hash_func_t)(hg_hash_table_key_t value)
Hash function used to generate hash values for keys used in a hash table.
HG_UTIL_EXPORT int hg_hash_table_iter_has_more(hg_hash_table_iter_t *iterator)
Determine if there are more keys in the hash table to iterate over.
void * hg_hash_table_key_t
A key to look up a value in a hg_hash_table_t.
int(* hg_hash_table_equal_func_t)(hg_hash_table_key_t value1, hg_hash_table_key_t value2)
Function used to compare two keys for equality.
void(* hg_hash_table_key_free_func_t)(hg_hash_table_key_t value)
Type of function used to free keys when entries are removed from a hash table.
HG_UTIL_EXPORT hg_hash_table_value_t hg_hash_table_iter_next(hg_hash_table_iter_t *iterator)
Using a hash table iterator, retrieve the next key.
HG_UTIL_EXPORT hg_hash_table_t * hg_hash_table_new(hg_hash_table_hash_func_t hash_func, hg_hash_table_equal_func_t equal_func)
Create a new hash table.
HG_UTIL_EXPORT void hg_hash_table_register_free_functions(hg_hash_table_t *hash_table, hg_hash_table_key_free_func_t key_free_func, hg_hash_table_value_free_func_t value_free_func)
Register functions used to free the key and value when an entry is removed from a hash table...
HG_UTIL_EXPORT void hg_hash_table_iterate(hg_hash_table_t *hash_table, hg_hash_table_iter_t *iter)
Initialise a HashTableIterator to iterate over a hash table.
struct hg_hash_table hg_hash_table_t
A hash table structure.
HG_UTIL_EXPORT int hg_hash_table_insert(hg_hash_table_t *hash_table, hg_hash_table_key_t key, hg_hash_table_value_t value)
Insert a value into a hash table, overwriting any existing entry using the same key.
HG_UTIL_EXPORT int hg_hash_table_remove(hg_hash_table_t *hash_table, hg_hash_table_key_t key)
Remove a value from a hash table.
struct hg_hash_table_entry hg_hash_table_entry_t
Internal structure representing an entry in a hash table.
HG_UTIL_EXPORT unsigned int hg_hash_table_num_entries(hg_hash_table_t *hash_table)
Retrieve the number of entries in a hash table.
HG_UTIL_EXPORT void hg_hash_table_free(hg_hash_table_t *hash_table)
Destroy a hash table.
hg_hash_table_t * hash_table
Definition of a hg_hash_table_iter.