Typedefs | |
typedef hash_table * | gdsl_hash_t |
GDSL hashtable type. | |
typedef const char *(* | gdsl_key_func_t )(void *VALUE) |
GDSL hashtable key function type. | |
typedef const ulong(* | gdsl_hash_func_t )(const char *KEY) |
GDSL hashtable hash function type. | |
Functions | |
const ulong | gdsl_hash (const char *KEY) |
Computes a hash value from a NULL terminated character string. | |
gdsl_hash_t | gdsl_hash_alloc (const char *NAME, gdsl_alloc_func_t ALLOC_F, gdsl_free_func_t FREE_F, gdsl_key_func_t KEY_F, gdsl_hash_func_t HASH_F, ushort INITIAL_ENTRIES_NB) |
Create a new hashtable. | |
void | gdsl_hash_free (gdsl_hash_t H) |
Destroy a hashtable. | |
void | gdsl_hash_flush (gdsl_hash_t H) |
Flush a hashtable. | |
const char * | gdsl_hash_get_name (const gdsl_hash_t H) |
Get the name of a hashtable. | |
ushort | gdsl_hash_get_entries_number (const gdsl_hash_t H) |
Get the number of entries of a hashtable. | |
ushort | gdsl_hash_get_lists_max_size (const gdsl_hash_t H) |
Get the max number of elements allowed in each entry of a hashtable. | |
ushort | gdsl_hash_get_longest_list_size (const gdsl_hash_t H) |
Get the number of elements of the longest list entry of a hashtable. | |
ulong | gdsl_hash_get_size (const gdsl_hash_t H) |
Get the size of a hashtable. | |
double | gdsl_hash_get_fill_factor (const gdsl_hash_t H) |
Get the fill factor of a hashtable. | |
gdsl_hash_t | gdsl_hash_set_name (gdsl_hash_t H, const char *NEW_NAME) |
Set the name of a hashtable. | |
gdsl_element_t | gdsl_hash_insert (gdsl_hash_t H, void *VALUE) |
Insert an element into a hashtable (PUSH). | |
gdsl_element_t | gdsl_hash_remove (gdsl_hash_t H, const char *KEY) |
Remove an element from a hashtable (POP). | |
gdsl_hash_t | gdsl_hash_delete (gdsl_hash_t H, const char *KEY) |
Delete an element from a hashtable. | |
gdsl_hash_t | gdsl_hash_modify (gdsl_hash_t H, ushort NEW_ENTRIES_NB, ushort NEW_LISTS_MAX_SIZE) |
Increase the dimensions of a hashtable. | |
gdsl_element_t | gdsl_hash_search (const gdsl_hash_t H, const char *KEY) |
Search for a particular element into a hashtable (GET). | |
gdsl_element_t | gdsl_hash_map (const gdsl_hash_t H, gdsl_map_func_t MAP_F, void *USER_DATA) |
Parse a hashtable. | |
void | gdsl_hash_write (const gdsl_hash_t H, gdsl_write_func_t WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA) |
Write all the elements of a hashtable to a file. | |
void | gdsl_hash_write_xml (const gdsl_hash_t H, gdsl_write_func_t WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA) |
Write the content of a hashtable to a file into XML. | |
void | gdsl_hash_dump (const gdsl_hash_t H, gdsl_write_func_t WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA) |
Dump the internal structure of a hashtable to a file. |
|
GDSL hashtable hash function type.
Definition at line 69 of file gdsl_hash.h. |
|
GDSL hashtable type. This type is voluntary opaque. Variables of this kind could'nt be directly used, but by the functions of this module. Definition at line 53 of file gdsl_hash.h. |
|
GDSL hashtable key function type.
Definition at line 61 of file gdsl_hash.h. |
|
Computes a hash value from a NULL terminated character string. This function computes a hash value from the NULL terminated KEY string.
|
|
Create a new hashtable. Allocate a new hashtable data structure which name is set to a copy of NAME. The new hashtable will contain initially INITIAL_ENTRIES_NB lists. This value could be (only) increased with gdsl_hash_modify() function. Until this function is called, then all H's lists entries have no size limit. The function pointers ALLOC_F and FREE_F could be used to respectively, alloc and free elements in the hashtable. The KEY_F function must provide a unique key associated to its argument. The HASH_F function must compute a hash code from its argument. These pointers could be set to NULL to use the default ones:
|
|
Delete an element from a hashtable. Remove from he hashtable H the first founded element E equal to KEY. If E is found, it is removed from H and E is deallocated using H's FREE_F function passed to gdsl_hash_alloc(), then H is returned.
|
|
Dump the internal structure of a hashtable to a file. Dump the structure of the hashtable H to OUTPUT_FILE. If WRITE_F != NULL, then uses WRITE_F to write H's elements to OUTPUT_FILE. Additionnal USER_DATA argument could be passed to WRITE_F.
|
|
Flush a hashtable. Deallocate all the elements of the hashtable H by calling H's FREE_F function passed to gdsl_hash_alloc(). H is not deallocated itself and H's name is not modified.
|
|
Destroy a hashtable. Deallocate all the elements of the hashtable H by calling H's FREE_F function passed to gdsl_hash_alloc(). The name of H is deallocated and H is deallocated itself too.
|
|
Get the number of entries of a hashtable.
|
|
Get the fill factor of a hashtable.
|
|
Get the max number of elements allowed in each entry of a hashtable.
|
|
Get the number of elements of the longest list entry of a hashtable.
|
|
Get the name of a hashtable.
|
|
Get the size of a hashtable.
|
|
Insert an element into a hashtable (PUSH). Allocate a new element E by calling H's ALLOC_F function on VALUE. The key K of the new element E is computed using KEY_F called on E. If the value of gdsl_hash_get_lists_max_size(H) is not reached, or if it is equal to zero, then the insertion is simple. Otherwise, H is re-organized as follow:
|
|
Parse a hashtable. Parse all elements of the hashtable H. The MAP_F function is called on each H's element with USER_DATA argument. If MAP_F returns GDSL_MAP_STOP then gdsl_hash_map() stops and returns its last examinated element.
|
|
Increase the dimensions of a hashtable. The hashtable H is re-organized to have NEW_ENTRIES_NB lists entries. Each entry is limited to NEW_LISTS_MAX_SIZE elements. After a call to this function, all insertions into H will make H automatically growing if needed. The grow is needed each time an insertion makes an entry list to reach NEW_LISTS_MAX_SIZE elements. In this case, H will be reorganized automatically by gdsl_hash_insert().
|
|
Remove an element from a hashtable (POP). Search into the hashtable H for the first element E equal to KEY. If E is found, it is removed from H and then returned.
|
|
Search for a particular element into a hashtable (GET). Search the first element E equal to KEY in the hashtable H.
|
|
Set the name of a hashtable. Change the previous name of the hashtable H to a copy of NEW_NAME.
|
|
Write all the elements of a hashtable to a file. Write the elements of the hashtable H to OUTPUT_FILE, using WRITE_F function. Additionnal USER_DATA argument could be passed to WRITE_F.
|
|
Write the content of a hashtable to a file into XML. Write the elements of the hashtable H to OUTPUT_FILE, into XML language. If WRITE_F != NULL, then uses WRITE_F to write H's elements to OUTPUT_FILE. Additionnal USER_DATA argument could be passed to WRITE_F.
|