Unordered Array / Counted Set

Yep, a counted, unordered, hashed multiset could be a reasonable addition to the package. I think this is mostly an API design challenge, rather than a data structure implementation task, as [Element: Int] seems like the right data structure for implementing such a set.

We discussed this a little bit in Counted Set · Issue #20 · apple/swift-collections · GitHub.

Whether this proves to be a worthy addition depends on how much better API the wrapper type provides over a raw dictionary of integers -- and on how well the design would translate to the other multiset variants that we will likely want to add, including the non-counting SortedMultiset. (There are fundamental differences between these two that I expect will be reflected in their API; but how much do they have in common? And what other multiset-like things do we need to consider?)

1 Like