swift-collections icon indicating copy to clipboard operation
swift-collections copied to clipboard

Bi-directional multimap?

Open orj opened this issue 4 years ago • 0 comments

Recently I encountered an issue where I needed a data structure that provided an efficient way of storing multiple values per key and being able to query for all keys that had a value.

A one way multi-value map can be implemented using Dictionary<Key, Set<Value>> but to get the keys that match values requires maintaining another Dictionary<Value, Set<Key>>. It would be nice if Swift had an efficient Bidirectional Multimap.

orj avatar May 28 '21 05:05 orj