23 #ifndef newgen_hash_included
24 #define newgen_hash_included
26 #define HASH_DEFAULT_SIZE 7
49 #define hash_table_undefined ((hash_table)gen_chunk_undefined)
50 #define hash_table_undefined_p(h) ((h)==hash_table_undefined)
56 #define HASH_UNDEFINED_VALUE ((void *) gen_chunk_undefined)
58 #define hash_table_empty_p(htp) (hash_table_entry_count(htp) == 0)
60 #define HASH_MAP(k, v, code, ht) \
62 hash_table NGMID(h) = (ht) ; \
63 register void * NGMID(i) = NULL; \
66 hash_table_scan(NGMID(h), NGMID(i), &k, &v))) { \
71 #define HASH_FOREACH(key_type, k, value_type, v, ht) \
72 hash_table NGMID(h) = (ht); \
73 register void * NGMID(i) = NULL; \
77 hash_table_scan(NGMID(h), NGMID(i), (void**) &k, (void**) &v)))
80 #define hash_put_or_update(h, k, v) hash_overwrite(h, k, v)
void const char const char const int
void hash_table_print_header(const hash_table, FILE *)
this function prints the header of the hash_table pointed to by htp on the opened stream fout.
void hash_update(hash_table, const void *, const void *)
update key->val in htp, that MUST be pre-existent.
void hash_map_put(hash_table, const void *, const void *)
int hash_table_entry_count(const hash_table)
now we define observers in order to hide the hash_table type...
list hash_get_default_empty_list(const hash_table, const void *)
Like hash_get() but returns an empty list instead of HASH_UNDEFINED_VALUE when a key is not found.
hash_key_type
Equality and rank functions are provided for strings, integers, pointers and Newgen chunks.
int hash_table_size(const hash_table)
returns the size of the internal array.
bool hash_map_defined_p(const hash_table, const void *)
_uint(* hash_rank_t)(const void *, size_t)
void hash_dont_warn_on_redefinition(void)
hash_table hash_table_make(hash_key_type key_type, size_t size)
void hash_overwrite(hash_table, const void *, const void *)
hash_put which allows silent overwrite...
bool hash_warn_on_redefinition_p(void)
void * hash_map_get(const hash_table, const void *)
newgen mapping to newgen hash...
hash_key_type hash_table_type(const hash_table)
returns the type of the hash_table.
void hash_table_fprintf(FILE *, gen_string_func_t, gen_string_func_t, const hash_table)
This function prints the content of the hash_table pointed to by htp on file descriptor f,...
void hash_table_print(const hash_table)
this function prints the content of the hash_table pointed to by htp on stderr.
void * hash_table_scan(const hash_table, void *, void **, void **)
void * hash_get(const hash_table, const void *)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
void hash_table_clear(hash_table)
Clears all entries of a hash table HTP.
_uint hash_string_rank(const void *, size_t)
en s'inspirant vaguement de Fast Hashing of Variable-Length Text Strings Peter K.
void hash_warn_on_redefinition(void)
these function set the variable should_i_warn_on_redefinition to the value true or false
void * hash_del(hash_table, const void *)
this function removes from the hash table pointed to by htp the couple whose key is equal to key.
void hash_put(hash_table, const void *, const void *)
This functions stores a couple (key,val) in the hash table pointed to by htp.
int hash_table_own_allocated_memory(const hash_table)
hash_table hash_table_generic_make(hash_key_type key_type, size_t size, hash_equals_t equals_p, hash_rank_t rank)
this function makes a hash table of size size.
void hash_map_update(hash_table, const void *, const void *)
void * hash_map_del(const hash_table, const void *)
hash_rank_t hash_table_rank_function(const hash_table)
int(* hash_equals_t)(const void *, const void *)
hash_equals_t hash_table_equals_function(const hash_table)
Because the hash table data structure is hidden in this source file hash.c and not exported via the n...
struct __hash_table * hash_table
Define hash_table structure which is hidden.
bool hash_defined_p(const hash_table, const void *)
true if key has e value in htp.
void * hash_delget(hash_table, const void *, void **)
deletes key from the hash table.
void hash_table_free(hash_table)
this function deletes a hash table that is no longer useful.
string(* gen_string_func_t)(const void *)
The structure used to build lists in NewGen.