Defines | |
#define | U_HMAP_MAX_SIZE 512 |
#define | U_HMAP_MAX_ELEMS U_HMAP_MAX_SIZE |
#define | U_HMAP_RATE_FULL 0.75 |
#define | U_HMAP_RATE_RESIZE 3 |
Typedefs | |
typedef u_hmap_q_h_s | u_hmap_q_h_t |
typedef u_hmap_e_s | u_hmap_e_t |
Functions | |
const char * | u_hmap_strerror (u_hmap_ret_t rc) |
Get a string representation of an error code. | |
int | u_hmap_new (u_hmap_opts_t *opts, u_hmap_t **hmap) |
Create a new hmap. | |
int | u_hmap_copy (u_hmap_t *to, u_hmap_t *from) |
Copy hmap. | |
void | u_hmap_dbg (u_hmap_t *hmap) |
Debug Hmap. | |
int | u_hmap_del (u_hmap_t *hmap, void *key, u_hmap_o_t **obj) |
void | u_hmap_pcy_dbg (u_hmap_t *hmap) |
Debug policy. | |
int | u_hmap_put (u_hmap_t *hmap, u_hmap_o_t *obj, u_hmap_o_t **old) |
Insert an object into the hmap. | |
int | u_hmap_get (u_hmap_t *hmap, void *key, u_hmap_o_t **obj) |
Retrieve an object from the hmap. | |
int | u_hmap_foreach (u_hmap_t *hmap, int f(void *val)) |
Perform an operation on all objects. | |
int | u_hmap_foreach_keyval (u_hmap_t *hmap, int f(void *key, void *val)) |
Perform an operation on all objects. | |
void | u_hmap_free (u_hmap_t *hmap) |
Deallocate hmap. | |
int | u_hmap_opts_new (u_hmap_opts_t **opts) |
Create new hmap options. | |
int | u_hmap_opts_copy (u_hmap_opts_t *to, u_hmap_opts_t *from) |
Copy options. | |
void | u_hmap_opts_init (u_hmap_opts_t *opts) |
Initialise hmap options. | |
void | u_hmap_opts_free (u_hmap_opts_t *opts) |
Deallocate hmap options. | |
void | u_hmap_opts_dbg (u_hmap_opts_t *opts) |
Debug options. | |
u_hmap_o_t * | u_hmap_o_new (void *key, void *val) |
Create a data object. | |
void | u_hmap_o_free (u_hmap_o_t *obj) |
Free a data object. |
|
Perform a copy of an hmap from to to by rehashing all elements and copying the object pointers to the new locations.
Definition at line 299 of file srcs/toolbox/hmap.c. References u_hmap_put(). |
|
Print out information on an hmap.
Definition at line 329 of file srcs/toolbox/hmap.c. References u_string_append(), u_string_c(), u_string_clear(), u_string_create(), u_string_free(), and u_string_len(). |
|
Execute function f on all objects within hmap. These functions should return U_HMAP_ERR_NONE on success, and take an object as a parameter.
Definition at line 844 of file srcs/toolbox/hmap.c. |
|
Execute function f on all objects within hmap. These functions should return U_HMAP_ERR_NONE on success, and take an object as a parameter.
Definition at line 875 of file srcs/toolbox/hmap.c. |
|
Deallocate hmap along with all hmapd objects (unless U_HMAP_OPTS_OWNSDATA is set). Objects are freed via free() by default or using the custom deallocation function passed in the hmap options.
Definition at line 904 of file srcs/toolbox/hmap.c. References u_free(). |
|
Retrieve object with given key from hmap. On success the requested object is returned in obj. The object is not removed from the hmap, so ownership of the object is not returned to the user.
Definition at line 811 of file srcs/toolbox/hmap.c. References u_hmap_o_s::pqe. |
|
Create a new hmap object and save its pointer to *hmap. The call may fail on memory allocation problems or if the options are manipulated incorrectly.
Definition at line 242 of file srcs/toolbox/hmap.c. References u_free(), u_hmap_opts_copy(), u_hmap_opts_dbg(), u_hmap_opts_new(), U_HMAP_RATE_FULL, and u_zalloc(). |
|
Frees a data object (without freeing its content). This function should only be used if U_HMAP_OPTS_OWNSDATA is not set to free objects allocated with u_hmap_o_new(). If U_HMAP_OPTS_OWNSDATA is set, the data is freed automatically by the hashmap by using the default free function or the overridden f_free().
Definition at line 1093 of file srcs/toolbox/hmap.c. References u_free(). |
|
Creates a new (key, value) tuple to be inserted into a hmap. By default, the user is responsible for allocation and deallocation of these objects and their content. If the option U_HMAP_OPTS_OWNSDATA is set
Definition at line 1061 of file srcs/toolbox/hmap.c. References u_hmap_o_s::key, u_hmap_o_s::pqe, u_free(), u_zalloc(), and u_hmap_o_s::val. |
|
Perform a deep copy of options object from to to.
Definition at line 977 of file srcs/toolbox/hmap.c. Referenced by u_hmap_new(). |
|
Print out information on option settings.
Definition at line 1035 of file srcs/toolbox/hmap.c. References u_hmap_opts_s::f_free, u_hmap_opts_s::max, u_hmap_opts_s::options, u_hmap_opts_s::policy, and u_hmap_opts_s::size. Referenced by u_hmap_new(). |
|
Deallocate hmap options object opts.
Definition at line 1021 of file srcs/toolbox/hmap.c. References u_free(). |
|
Set allocated hmap options to default values
Definition at line 997 of file srcs/toolbox/hmap.c. References u_hmap_opts_s::f_comp, u_hmap_opts_s::f_free, u_hmap_opts_s::f_hash, u_hmap_opts_s::f_str, u_hmap_opts_s::max, u_hmap_opts_s::options, u_hmap_opts_s::policy, u_hmap_opts_s::size, u_hmap_opts_s::type, U_HMAP_MAX_ELEMS, and U_HMAP_MAX_SIZE. Referenced by u_hmap_opts_new(). |
|
Create a new hmap options object and save its pointer to *opts. The fields within the object can be manipulated publicly according to the description in the header file.
Definition at line 948 of file srcs/toolbox/hmap.c. References u_hmap_opts_init(), and u_zalloc(). Referenced by u_hmap_new(). |
|
Print out policy information.
Definition at line 490 of file srcs/toolbox/hmap.c. References u_string_append(), u_string_c(), u_string_clear(), u_string_create(), and u_string_free(). |
|
Insert a (key, val) pair obj into hmap. Such object should be created with u_hmap_o_new(). The user is responsible for allocation of keys and values unless U_HMAP_OPTS_OWNSDATA is set. If a value is overwritten, the old value is returned (only if data is owned by user).
Definition at line 634 of file srcs/toolbox/hmap.c. References u_hmap_o_s::key, u_hmap_o_s::pqe, and u_snprintf(). Referenced by u_hmap_copy(). |
|
Get a string representation of an error code
Definition at line 101 of file srcs/toolbox/hmap.c. |