aboutsummaryrefslogtreecommitdiff
path: root/collections/map/map.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'collections/map/map.adoc')
-rw-r--r--collections/map/map.adoc49
1 files changed, 49 insertions, 0 deletions
diff --git a/collections/map/map.adoc b/collections/map/map.adoc
index 740df3c..690aa3d 100644
--- a/collections/map/map.adoc
+++ b/collections/map/map.adoc
@@ -119,6 +119,55 @@ assert(strcmp(tmp, "FOUR") == 0);
free(tmp);
----
+[[map_first]]
++void* map_first(map *self)+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Returns the value associated with the smallest key from +self+.
+
+Examples
+^^^^^^^^
+[source,c]
+----
+#include "map.h"
+#include <string.h>
+
+char *str1 = "A";
+char *str2 = "Z";
+
+map *dict = map_new((cmp_func) strcmp);
+
+map_insert(dict, str1, str1);
+map_insert(dict, str2, str2);
+
+
+assert(strcmp(str1, map_first(dict) == 0);
+----
+
+[[map_last]]
++void* map_last(map *self)+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Returns the value associated with the largest key from +self+.
+
+Examples
+^^^^^^^^
+[source,c]
+----
+#include "map.h"
+#include <string.h>
+
+char *str1 = "A";
+char *str2 = "Z";
+
+map *dict = map_new((cmp_func) strcmp);
+
+map_insert(dict, str1, str1);
+map_insert(dict, str2, str2);
+
+
+assert(strcmp(str2, map_last(dict) == 0);
+----
+
+
[[map_swap]]
+void map_swap(map *self, void *i, void *j)+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~