Files
swift-mirror/unittests/Basic/FrozenMultiMapTest.cpp
Michael Gottesman 9568d53c8f [frozen-multimap] Add support for erasing once we have finished constructing the map.
I implemented this in a similar way to the way blotting is implemented in a blot
map vector:

1. I changed this to store (Key, Optional<Value>) pairs.

2. I made it so that once frozen, we can "erase" things from the multimap by
setting all Optional<Value> to none.

3. I changed the range we vend to be an OptionalTransformRange instead of just a
TransformRange so we skip all keys with .none values, meaning that a user will
get the nice behavior that getRange() still works after erasing.

One interesting thing to note is that one /cannot/ erase elements when
initializing the frozen multi-map since we haven't sorted it yet. At first this
seems weird, but it actually fits with the use case of this data structure:
building up state by processing IR in a readonly way and then later working with
it in a worklist like way (and perhaps checking for unhandled cases at the end
of processing).

The nice thing additional thing is that I was able to ensure that the actual
exposed API did not change in terms of how one uses it. I just changed the
underlying iterators/etc.
2020-04-28 15:03:45 -07:00

7.8 KiB