mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
7.8 KiB
7.8 KiB