aboutsummaryrefslogtreecommitdiff
path: root/collections/map/map.adoc
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-07-06 20:50:38 -0400
committerTucker Evans <tucker@tuckerevans.com>2020-07-08 11:03:54 -0400
commit15de5dc2c5d82e816cd9c0a7c56b7e1d4165717f (patch)
tree5b8a61fc0978046b6f3107c7454cd690845d81e0 /collections/map/map.adoc
parent7d69ea177200bda62b403eb9ead6eee2ba5abe52 (diff)
Add index function for maps
Diffstat (limited to 'collections/map/map.adoc')
-rw-r--r--collections/map/map.adoc20
1 files changed, 19 insertions, 1 deletions
diff --git a/collections/map/map.adoc b/collections/map/map.adoc
index 2822b79..da0ebaf 100644
--- a/collections/map/map.adoc
+++ b/collections/map/map.adoc
@@ -1,7 +1,7 @@
Map
===
Tucker Evans
-v0.4, 2020-07-06
+v0.5, 2020-07-06
A basic map implemented in an AVL tree.
@@ -113,6 +113,24 @@ free(map_reset_key(dict "ONE"));
assert(map_insert(dict, "ONE", "NEW_VALUE") == 0);
----
+[[map_index]]
++void* map_index(map *self, vaid *key)+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Returns the value associated with +key+ (or equivalent).
+
+Examples
+^^^^^^^^
+[source,c]
+----
+#include "map.h"
+#include <string.h>
+
+map *dict = map_new((cmp_func) strcmp, sizeof(char*));
+
+map_insert(dict, strdup("ONE"), "VALUE");
+assert(strcmp(map_index(dict, "ONE"), "VALUE") == 0);
+----
+
[[map_clear]]
+void map_clear(map *self)+
~~~~~~~~~~~~~~~~~~~~~~~~~~~