aboutsummaryrefslogtreecommitdiff
path: root/collections/map/map.c
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2020-07-24 15:56:43 -0400
committerTucker Evans <tuckerevans24@gmail.com>2020-07-24 15:56:43 -0400
commitde41cfb61d4cbafdc3ffe8a2651630a53b3c8d11 (patch)
tree468869fa0550c2ce65ce1b1c02e66b7fd2701ec0 /collections/map/map.c
parentbc540d32e8d2ff16ffe688b02f18d565651e4b10 (diff)
Add first/last getters for maps.maps
Diffstat (limited to 'collections/map/map.c')
-rw-r--r--collections/map/map.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/collections/map/map.c b/collections/map/map.c
index b0e095e..d581d81 100644
--- a/collections/map/map.c
+++ b/collections/map/map.c
@@ -497,6 +497,30 @@ void *key;
return ret;
}
+void* map_first(root)
+map *root;
+{
+ struct map_node *tmp;
+
+ if (!root)
+ return;
+
+ for (tmp = root->root; tmp->left; tmp = tmp->left);
+ return tmp->val;
+}
+
+void* map_last(root)
+map *root;
+{
+ struct map_node *tmp;
+
+ if (!(root || root->root))
+ return;
+
+ for (tmp = root->root; tmp->right; tmp = tmp->right);
+ return tmp->val;
+}
+
void map_swap(root, ikey, jkey)
map *root;
void *ikey, *jkey;