aboutsummaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 44ee869cb..d0703378c 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -215,14 +215,15 @@ struct Map {
Array<MapEntry<T> > entries;
};
-template <typename T> void map_init (Map<T> *h, gbAllocator a);
-template <typename T> void map_destroy(Map<T> *h);
-template <typename T> T * map_get (Map<T> *h, HashKey key);
-template <typename T> void map_set (Map<T> *h, HashKey key, T value);
-template <typename T> void map_remove (Map<T> *h, HashKey key);
-template <typename T> void map_clear (Map<T> *h);
-template <typename T> void map_grow (Map<T> *h);
-template <typename T> void map_rehash (Map<T> *h, isize new_count);
+template <typename T> void map_init (Map<T> *h, gbAllocator a);
+template <typename T> void map_init_with_reserve(Map<T> *h, gbAllocator a, isize capacity);
+template <typename T> void map_destroy (Map<T> *h);
+template <typename T> T * map_get (Map<T> *h, HashKey key);
+template <typename T> void map_set (Map<T> *h, HashKey key, T value);
+template <typename T> void map_remove (Map<T> *h, HashKey key);
+template <typename T> void map_clear (Map<T> *h);
+template <typename T> void map_grow (Map<T> *h);
+template <typename T> void map_rehash (Map<T> *h, isize new_count);
template <typename T> MapEntry<T> *multi_map_find_first(Map<T> *h, HashKey key);
template <typename T> MapEntry<T> *multi_map_find_next (Map<T> *h, MapEntry<T> *e);
@@ -243,6 +244,12 @@ gb_inline void map_init(Map<T> *h, gbAllocator a) {
}
template <typename T>
+gb_inline void map_init_with_reserve(Map<T> *h, gbAllocator a, isize capacity) {
+ array_init(&h->hashes, a, capacity);
+ array_init(&h->entries, a, capacity);
+}
+
+template <typename T>
gb_inline void map_destroy(Map<T> *h) {
array_free(&h->entries);
array_free(&h->hashes);