|
Tinyhash
This is a library containing multiple C implementations of hashmap.
|


Go to the source code of this file.
Classes | |
| struct | th_funcs_t |
| Centralizing every function associated with an unique implementation method. More... | |
| struct | th_t |
| Represent a hashmap controller. More... | |
Typedefs | |
| typedef th_generic_table_t(* | th_create_func_t) (void) |
| Pointer on generic function that create a table. | |
| typedef th_any_t(* | th_get_func_t) (th_generic_table_t, th_any_t, size_t) |
| Pointer on generic function that get a value from a table. | |
| typedef bool(* | th_put_func_t) (th_generic_table_t, th_any_t, size_t, th_any_t) |
| Pointer on generic function that insert a value into a table. | |
| typedef bool(* | th_delete_func_t) (th_generic_table_t, th_any_t, size_t) |
| Pointer on generic function that delete a value from a table. | |
| typedef void(* | th_free_func_t) (th_generic_table_t) |
| Pointer on generic function that free a table. | |
| typedef th_iterator_t *(* | th_begin_iterator_func_t) (th_generic_table_t, bool) |
| typedef int(* | th_len_func_t) (th_generic_table_t) |
Enumerations | |
| enum | th_method_t { TH_SEPARATE_CHAINING , TH_OPEN_ADRESSING } |
| Implementation methods. More... | |
Functions | |
| th_t | th_create (th_method_t method) |
| Allocate then initialize a hashmap controller. based on the given method. | |
| th_t | th_create_default () |
| Allocate then initialize a hashmap controller with its default values. | |
| th_any_t | th_get (th_t *th, th_any_t data, size_t data_size) |
| Returns a value from a hashmap. Return NULL if it doest not exist. | |
| bool | th_put (th_t *th, th_any_t data, size_t data_size, th_any_t value) |
| Insert element within the hashmap. Return true on success. | |
| bool | th_delete (th_t *th, th_any_t data, size_t data_size) |
| Delete a key value pair from a hashmap. Return true on success. | |
| void | th_clear (th_t *th) |
| Clear a hashmap. | |
| void | th_free (th_t *th) |
| Free a hashmap. | |
| th_iterator_t * | th_begin_iterator (th_t *th) |
| Return a pointer on an iterator with the first element. | |
| th_iterator_t * | th_empty_iterator (th_t *th) |
| Return an empty iterator. | |
| int | th_len (th_t *th) |
| Get the hashmap length (total amount of key value pairs). | |
| typedef th_iterator_t *(* th_begin_iterator_func_t) (th_generic_table_t, bool) |
Definition at line 49 of file tinyhash.h.
| typedef th_generic_table_t(* th_create_func_t) (void) |
Pointer on generic function that create a table.
Definition at line 23 of file tinyhash.h.
| typedef bool(* th_delete_func_t) (th_generic_table_t, th_any_t, size_t) |
Pointer on generic function that delete a value from a table.
Definition at line 41 of file tinyhash.h.
| typedef void(* th_free_func_t) (th_generic_table_t) |
Pointer on generic function that free a table.
Definition at line 47 of file tinyhash.h.
| typedef th_any_t(* th_get_func_t) (th_generic_table_t, th_any_t, size_t) |
Pointer on generic function that get a value from a table.
Definition at line 29 of file tinyhash.h.
| typedef int(* th_len_func_t) (th_generic_table_t) |
Definition at line 50 of file tinyhash.h.
| typedef bool(* th_put_func_t) (th_generic_table_t, th_any_t, size_t, th_any_t) |
Pointer on generic function that insert a value into a table.
Definition at line 35 of file tinyhash.h.
| enum th_method_t |
Implementation methods.
| Enumerator | |
|---|---|
| TH_SEPARATE_CHAINING | |
| TH_OPEN_ADRESSING | |
Definition at line 14 of file tinyhash.h.
| th_iterator_t * th_begin_iterator | ( | th_t * | th | ) |
Return a pointer on an iterator with the first element.
| th |
Definition at line 73 of file tinyhash.c.
References th_funcs_t::begin_iterator, th_t::funcs, and th_t::table.
| void th_clear | ( | th_t * | th | ) |
Clear a hashmap.
| th |
Definition at line 65 of file tinyhash.c.
References th_funcs_t::_free, th_t::funcs, and th_t::table.
| th_t th_create | ( | th_method_t | method | ) |
Allocate then initialize a hashmap controller. based on the given method.
| method |
Definition at line 39 of file tinyhash.c.
References th_funcs_t::create, th_create_default(), th_funcs, and th_funcs_length.
Referenced by th_create_default().


| th_t th_create_default | ( | ) |
Allocate then initialize a hashmap controller with its default values.
Definition at line 37 of file tinyhash.c.
References th_create(), and TH_SEPARATE_CHAINING.
Referenced by th_create().


Delete a key value pair from a hashmap. Return true on success.
| th | |
| data | |
| data_size |
Definition at line 61 of file tinyhash.c.
References th_funcs_t::_delete, th_t::funcs, and th_t::table.
| th_iterator_t * th_empty_iterator | ( | th_t * | th | ) |
Return an empty iterator.
| th |
Definition at line 77 of file tinyhash.c.
References th_funcs_t::begin_iterator, th_t::funcs, and th_t::table.
| void th_free | ( | th_t * | th | ) |
Free a hashmap.
| th |
Definition at line 67 of file tinyhash.c.
References th_funcs_t::_free, th_t::funcs, and th_t::table.
Returns a value from a hashmap. Return NULL if it doest not exist.
| th | |
| data | |
| data_size |
Definition at line 53 of file tinyhash.c.
References th_t::funcs, th_funcs_t::get, and th_t::table.
| int th_len | ( | th_t * | th | ) |
Get the hashmap length (total amount of key value pairs).
| th |
Definition at line 81 of file tinyhash.c.
References th_t::funcs, th_funcs_t::len, and th_t::table.
Insert element within the hashmap. Return true on success.
| th | |
| data | |
| data_size | |
| value |
Definition at line 57 of file tinyhash.c.
References th_t::funcs, th_funcs_t::put, and th_t::table.