I have HashMap with some record. I need last record without key from HashMap.
map.put("key1", 1);
map.put("key2", 2);
map.put("key3", 3);
map.put("key4", 3);
map.put("key5", 2);
map.put("key6", 2);
let map2 =
HashMap.mapFilter<Text, Nat, Nat>(
map,
Text.equal,
Text.hash,
func (k, v) = if (v == 2) { null } else { ?(v == 3)}
);
so, for example map2 have two record
map.put("key3", 3);
map.put("key4", 3); // <= Last Record
How to get last record without key?
Fun fact: the map mentioned above follows the pattern in V8 (the chrome engine). Iām guessing that boa(the rust based js engine that I think Azel
Uses) likely borrowed from this as well.
Th e latest motoko version has puhfront, popfront, pushBack, popBack, an a few forward and backward iterators as well.