Data Structures |
struct | AssocAndDestroy |
Defines |
#define | ASSOC_CONTINUE ST_CONTINUE |
#define | ASSOC_DELETE ST_DELETE |
| Simple assscoiative list.
|
#define | ASSOC_FOREACH(table, iter, key, value) st_foreach_item(table, iter, key, value) |
| Iterate over all k-v pairs in the assoc.
|
#define | assoc_get_size(table) st_count(table) |
| Retrieve the number of elements in the hash.
|
#define | assoc_iter_free(iter) st_free_gen(iter) |
| Generates a new iterator for the given hash.
|
#define | assoc_iter_init(table) st_init_gen(table) |
| Generates a new iterator for the given hash.
|
#define | assoc_iter_next(iter, key, value) st_gen(iter, key, value) |
| Iterate over all k-v pairs in the assoc.
|
#define | ASSOC_STOP ST_STOP |
Typedefs |
typedef st_generator * | assoc_iter |
typedef enum st_retval | assoc_retval |
typedef struct
AssocAndDestroy_TAG * | AssocAndDestroy_ptr |
typedef ST_PFSR | PF_STCPCPCP |
Functions |
hash_ptr | assoc_deep_copy (hash_ptr hash, ST_PFSR copy_fun) |
void | assoc_foreach (hash_ptr hash, ST_PFSR fn, char *arg) |
| Iterates over the elements of the hash.
|
node_ptr | assoc_get_keys (hash_ptr hash, NodeMgr_ptr nodemgr, boolean ignore_nils) |
| Returns the list of inserted keys. If parameter ignore_nils is true, the those keys whose associated values are Nil (typically, removed associations) will not be added to the returned list. Entries in the returned list are presented in an arbitrary order. NOTE: the invoker has to free the list (see free_list) after using it.
|
void | clear_assoc (hash_ptr hash) |
void | clear_assoc_and_free_entries (hash_ptr, ST_PFSR) |
| this is actually a very general function
|
void | clear_assoc_and_free_entries_arg (hash_ptr hash, ST_PFSR fn, char *arg) |
| this is actually a very general function
|
hash_ptr | copy_assoc (hash_ptr hash) |
node_ptr | find_assoc (hash_ptr, node_ptr) |
void | free_assoc (hash_ptr hash) |
| Frees any internal storage associated with the hash table. It's user responsibility to free any storage associated with the pointers in the table.
|
void | insert_assoc (hash_ptr, node_ptr, node_ptr) |
hash_ptr | new_assoc (void) |
hash_ptr | new_assoc_string_key (void) |
hash_ptr | new_assoc_with_params (ST_PFICPCP compare_fun, ST_PFICPI hash_fun) |
hash_ptr | new_assoc_with_size (int initial_size) |
node_ptr | remove_assoc (hash_ptr hash, node_ptr key) |
| Removes a key from the table. Returns the data associated with the given key, and if the key has not been in the table then Nil is returned.
|
#define ASSOC_FOREACH |
( |
table, |
|
|
iter, |
|
|
key, |
|
|
value |
|
) |
st_foreach_item(table, iter, key, value) |
Iterate over all k-v pairs in the assoc.
Iterate over all k-v pairs in the assoc.
IMPORTANT NOTE: If the loop is interrupted (e.g. by a "break" call, the iterator must be freed manually
Expected types: st_table* table st_generator* iter char** key char** value
- Todo:
- Missing synopsis
- Todo:
- Missing description
void assoc_foreach |
( |
hash_ptr |
hash, |
|
|
ST_PFSR |
fn, |
|
|
char * |
arg | |
|
) |
| | |
Iterates over the elements of the hash.
For each (key, value) record in `hash', assoc_foreach call func with the arguments
(*func)(key, value, arg)
If func returns ASSOC_CONTINUE, st_foreach continues processing entries. If func returns ASSOC_STOP, st_foreach stops processing and returns immediately. If func returns ASSOC_DELETE, then the entry is deleted from the symbol table and st_foreach continues. In the case of ASSOC_DELETE, it is func's responsibility to free the key and value, if necessary.
None
Returns the list of inserted keys. If parameter ignore_nils is true, the those keys whose associated values are Nil (typically, removed associations) will not be added to the returned list. Entries in the returned list are presented in an arbitrary order. NOTE: the invoker has to free the list (see free_list) after using it.
WARNING: Calling this function is not free: The whole hash is traversed and the list of nodes is created (and has to be freed). Use ASSOC_FOREACH or assoc_foreach if possible