Thank you for this solution.
I needed to construct the Hash-Map and then use it. So there was no way of invalidating while using it, but I can see that such situations might occur.
If situations like this (storing multiple values to a key) appear quite frequently, maybe it might be worthwhile to put something like a std.AutoMultiHashMap(KeyType, ValueType)
into the std-lib that does exactly that.