From 50846316de122801e07511d4e3771a4561efa5ad Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Mon, 6 Jul 2020 15:49:49 -0400 Subject: Add size function for maps --- collections/map/map.adoc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'collections/map/map.adoc') diff --git a/collections/map/map.adoc b/collections/map/map.adoc index fc6b8b7..837a08a 100644 --- a/collections/map/map.adoc +++ b/collections/map/map.adoc @@ -1,7 +1,7 @@ Map === Tucker Evans -v0.1, 2020-07-06 +v0.2, 2020-07-06 A basic map implemented in an AVL tree. @@ -50,3 +50,22 @@ Examples map *dict = map_new((cmp_func) strcmp); ---- + +[[map_size]] ++map_size(map *self)+ +~~~~~~~~~~~~~~~~~~~~~ +Returns the number of key, value pairs stored in map +self+. + +Examples +^^^^^^^^ +[source,c] +---- +#include "map.h" +#include + +map *dict = map_new((cmp_func) strcmp); + +assert(map_size(dict) == 0); +map_set(dict, "ONE", NULL); +assert(map_size(dict) == 1); +---- -- cgit v1.1