aboutsummaryrefslogtreecommitdiff
path: root/src/hashmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashmap.h')
-rw-r--r--src/hashmap.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/hashmap.h b/src/hashmap.h
index 5a1e22d..981c21b 100644
--- a/src/hashmap.h
+++ b/src/hashmap.h
@@ -31,16 +31,27 @@ struct hashmap *hashmap_new_with_cap(size_t cap);
#define hashmap_new() hashmap_new_with_cap(HASHMAP_CAP)
+/*
+ * Inserts a key-value pair into the map. Returns NULL if map did not have key,
+ * old value if it did.
+ */
void *hashmap_insert(struct hashmap *hm, const char *key, void *value);
+/* Returns a pointer to the value corresponding to the key. */
void *hashmap_get(struct hashmap *hm, const char *key);
+/* Retrieve pointer to value by key, handles dot notation for nested hashmaps */
void *hashmap_resolve(struct hashmap *hm, const char *key);
+/*
+ * Removes a key from the map, returning the value at the key if the key was
+ * previously in the map.
+ */
void *hashmap_remove(struct hashmap *hm, const char *key);
+/* free hashmap related memory */
void hashmap_free(struct hashmap *hm);
-void hashmap_walk(struct hashmap *hm, void (*fn)(void *value));
+void hashmap_walk(struct hashmap *hm, void (*fn)(const void *key, void *value));
#endif