summaryrefslogtreecommitdiff
path: root/src/gehashmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gehashmap.h')
-rw-r--r--src/gehashmap.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gehashmap.h b/src/gehashmap.h
index 832d047..ccd7a60 100644
--- a/src/gehashmap.h
+++ b/src/gehashmap.h
@@ -42,7 +42,7 @@
\
/* A structure representing an actual hashmap */ \
typedef struct { \
- size_t __size, /* The number of used buckets */ \
+ size_t __size, /* The number of elements in the map */ \
__cap; /* The number of allocated buckets */ \
double __loadf; /* The % of the hashmap that must be
* filled before the map grows */ \
@@ -54,6 +54,7 @@
int n##_set(n_t *, k, v); \
bool n##_get(n_t *, k, v *); \
bool n##_has(n_t *, k); \
+ size_t n##_size(n_t *); \
int n##_remove(n_t *, k); \
int n##_resize(n_t *, size_t); \
bool n##_key_iseq(k, k); \
@@ -160,6 +161,13 @@
return n##_get(map, key, NULL); \
} \
\
+ /* Function to get the number of elements in a hashmap. */ \
+ size_t \
+ n##_size(n_t *map) \
+ { \
+ return map->__size; \
+ } \
+ \
/* Function to remove an element with a given key from a hashmap. If
* the key or value were dynamically allocated they will not be freed.
* On error -1 is returned, otherwise 0 is returned.