summaryrefslogtreecommitdiff
path: root/src/hashm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashm.h')
-rw-r--r--src/hashm.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/hashm.h b/src/hashm.h
index e1ed720..5e5e802 100644
--- a/src/hashm.h
+++ b/src/hashm.h
@@ -62,15 +62,17 @@ inline void wayc_hashmap_deinit(hashmap_s<K, V> *map) {
}
template <typename K, typename V>
-inline V *wayc_hashmap_insert(hashmap_s<K, V> *map, const K *key) {
+inline V *wayc_hashmap_insert(hashmap_s<K, V> *map, const K *key,
+ const V *value) {
wayc_notnull(map);
wayc_notnull(key);
+ wayc_notnull(value);
hashentry_s<K, V> entry{};
entry.key = *key;
- auto *stored = (hashentry_s<K, V> *)hashmap_set(map->inner, &entry);
+ entry.value = *value;
+ auto *stored = (hashentry_s<K, V> *)hashmap_insert(map->inner, &entry);
- wayc_notnull(stored);
return &stored->value;
}
@@ -87,3 +89,13 @@ inline V *wayc_hashmap_get(hashmap_s<K, V> *map, const K *key) {
return &stored->value;
}
+
+template <typename K, typename V>
+inline void wayc_hashmap_remove(hashmap_s<K, V> *map, const K *key) {
+ wayc_notnull(map);
+ wayc_notnull(key);
+
+ hashentry_s<K, V> entry{};
+ entry.key = *key;
+ hashmap_remove(map->inner, &entry);
+} \ No newline at end of file