summaryrefslogtreecommitdiff
path: root/src/gehashmap.h
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-01-02 00:23:24 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-01-02 00:23:24 +0100
commit62bb46a48cb9ecad96e1fe3591253243c2fb614e (patch)
tree07143b38e5bcbb2dad9e810b01a163b5ac3b464d /src/gehashmap.h
parent6337f29dd5310fd3c471ee1261077e755c3c2c39 (diff)
Add _empty() functions
Diffstat (limited to 'src/gehashmap.h')
-rw-r--r--src/gehashmap.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gehashmap.h b/src/gehashmap.h
index ccd7a60..c85695c 100644
--- a/src/gehashmap.h
+++ b/src/gehashmap.h
@@ -55,6 +55,7 @@
bool n##_get(n_t *, k, v *); \
bool n##_has(n_t *, k); \
size_t n##_size(n_t *); \
+ bool n##_empty(n_t *); \
int n##_remove(n_t *, k); \
int n##_resize(n_t *, size_t); \
bool n##_key_iseq(k, k); \
@@ -168,6 +169,13 @@
return map->__size; \
} \
\
+ /* Function to check if a hashmap is empty . */ \
+ bool \
+ n##_empty(n_t *map) \
+ { \
+ return map->__size == 0; \
+ } \
+ \
/* 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.