From cf427c05b05e0409cfdeb6bc30b69070dd1700c3 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Mon, 6 Jul 2020 15:39:08 -0400 Subject: Add constructor for maps --- collections/map/map.adoc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'collections/map/map.adoc') diff --git a/collections/map/map.adoc b/collections/map/map.adoc index a43ae1d..fc6b8b7 100644 --- a/collections/map/map.adoc +++ b/collections/map/map.adoc @@ -1,7 +1,7 @@ Map === Tucker Evans -v0.0, 2020-07-06 +v0.1, 2020-07-06 A basic map implemented in an AVL tree. @@ -30,3 +30,23 @@ first parameter. This is a pointer to a function that to compare keys from pointers. This typedef is provided to cast comparison functions as a map expects the comparison function to take void* as its parameters. + +Functions +--------- +[[map_new]] ++map_new(cmp_func cmp)+ +~~~~~~~~~~~~~~~~~~~~~~~ +Constructs an empty map. ++cmp+ should be a function that takes two pointers (+lhs+, +rhs+)to your value +type and returns (int) a negative value if +lhs+ is less than +rhs+, zero if ++lhs+ is equal to +rhs+, and positive value if +lhs+ is greater than +rhs+. + +Examples +^^^^^^^^ +[source,c] +---- +#include "map.h" +#include + +map *dict = map_new((cmp_func) strcmp); +---- -- cgit v1.1