Skip to content

@maps

Import this module with import @maps.

Function Signature Description
is_empty (m map[K:V]) -> bool Check if map is empty
has_key (m map[K:V], key K) -> bool Check if key exists
contains_value (m map[K:V], value V) -> bool Check if any entry has the given value
get_keys (m map[K:V]) -> [K] Get all keys as an array
get_values (m map[K:V]) -> [V] Get all values as an array
get_or_default (m map[K:V], key K, default V) -> V Get value or return default if key missing
remove_key (&m map[K:V], key K) Remove key-value pair; does nothing if key absent
clear (&m map[K:V]) Remove all entries
merge (m1 map[K:V], m2 map[K:V]) -> map[K:V] Combine two maps (m2 overwrites on conflict)
is_equal (a map[K:V], b map[K:V]) -> bool Structural equality. Compares counts, then iterates the first map’s entries in insertion order looking each key up in the second. K and V must each be a primitive (i64, u64, f64, bool, char, u8, sized variants) or string; maps with nested-composite values are rejected at compile time.

The == and != operators on maps are not allowed; use maps.is_equal(a, b) for equality. Maps have no defined ordering, so < / <= / > / >= on maps is also rejected.

Use len(m) to get the number of entries (builtin, no import needed).