From 021bcdcf21d9c11ef4c817bb2bb5f52c3867cfd4 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 10 May 2023 13:12:31 +0200 Subject: [PATCH] Add "is_initialized" to check if a map has been initialized. --- lib/std/collections/map.c3 | 11 +++++++++++ src/version.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/std/collections/map.c3 b/lib/std/collections/map.c3 index b61728389..6c265313f 100644 --- a/lib/std/collections/map.c3 +++ b/lib/std/collections/map.c3 @@ -45,6 +45,17 @@ fn void HashMap.tinit(HashMap* map, uint capacity = DEFAULT_INITIAL_CAPACITY, fl map.init(capacity, load_factor, mem::temp()); } +/** + * Has this hash map been initialized yet? + * + * @param [&in] map "The hash map we are testing" + * @return "Returns true if it has been initialized, false otherwise" + **/ +fn bool HashMap.is_initialized(HashMap* map) +{ + return map.allocator != null; +} + fn void HashMap.init_from_map(HashMap* map, HashMap* other_map, Allocator* using = mem::heap()) { map.init(other_map.table.len, other_map.load_factor, using); diff --git a/src/version.h b/src/version.h index 038f60e30..1e10a945f 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.508" \ No newline at end of file +#define COMPILER_VERSION "0.4.509" \ No newline at end of file