diff options
Diffstat (limited to 'collections/map/map.adoc')
-rw-r--r-- | collections/map/map.adoc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/collections/map/map.adoc b/collections/map/map.adoc index 4668e0e..2b3e2cb 100644 --- a/collections/map/map.adoc +++ b/collections/map/map.adoc @@ -1,7 +1,7 @@ Map === Tucker Evans -v0.2, 2020-07-06 +v0.3, 2020-07-06 A basic map implemented in an AVL tree. @@ -70,6 +70,28 @@ map_insert(dict, "ONE", NULL); assert(map_size(dict) == 1); ---- +[[map_insert]] ++int map_insert(map *self, void *key, void *value)+ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Inserts item +value+ for +key+ into +self+ +This returns an int indicating a successful insertion; currently the only +two potential errors are caused by a NULL map or an equivalent key with a +different pointer, this is in order to prevent a memory leak. +<<reset_key,+map_reset_key()+>> can be used to fix this issue. + +Examples +^^^^^^^^ +[source,c] +---- +#include "map.h" +#include <string.h> + +map *dict = map_new((cmp_func) strcmp); + +map_insert(dict, "ONE", NULL); +assert(map_size(dict) == 1); +---- + [[map_clear]] +void map_clear(map *self)+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |