Hash_Map module

for_expansion

procedureextensionsince 0.23.0Source

for value, key: map {...} visits every entry: it is the value (a pointer to it under for *), it_index the key. remove it takes the current entry out. Anything else that changes the map inside the loop, adding included, invalidates the loop.

Example↗
Hash_Map :: #import "Extensions/Hash_Map";

map: Hash_Map.Map(int, int);
defer Hash_Map.deinit(*map);

for 1..5 Hash_Map.insert(*map, it, it * 10);
for value, key: map if key % 2 == 0 remove value;
total := 0;
for value: map total += value;
assert(total == 90);
for_expansion :: (map: *$T/Map, body: Code, flags: For_Flags)

Parameters

map: *$T/Map
body: Code
flags: For_Flags

See also