mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-31 02:12:04 +00:00
Try try and or_else built-in procedures with operators try and try else
This commit is contained in:
@@ -69,6 +69,7 @@ struct Map {
|
||||
template <typename T> void map_init (Map<T> *h, gbAllocator a, isize capacity = 16);
|
||||
template <typename T> void map_destroy (Map<T> *h);
|
||||
template <typename T> T * map_get (Map<T> *h, HashKey const &key);
|
||||
template <typename T> T & map_must_get (Map<T> *h, HashKey const &key);
|
||||
template <typename T> void map_set (Map<T> *h, HashKey const &key, T const &value);
|
||||
template <typename T> void map_remove (Map<T> *h, HashKey const &key);
|
||||
template <typename T> void map_clear (Map<T> *h);
|
||||
@@ -202,6 +203,13 @@ T *map_get(Map<T> *h, HashKey const &key) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T &map_must_get(Map<T> *h, HashKey const &key) {
|
||||
isize index = map__find(h, key).entry_index;
|
||||
GB_ASSERT(index >= 0);
|
||||
return h->entries[index].value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void map_set(Map<T> *h, HashKey const &key, T const &value) {
|
||||
isize index;
|
||||
|
||||
Reference in New Issue
Block a user