From de41cfb61d4cbafdc3ffe8a2651630a53b3c8d11 Mon Sep 17 00:00:00 2001
From: Tucker Evans <tuckerevans24@gmail.com>
Date: Fri, 24 Jul 2020 15:56:43 -0400
Subject: Add first/last getters for maps.

---
 collections/map/map.adoc | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

(limited to 'collections/map/map.adoc')

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)+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
cgit v1.1

