is there a good equivalent of a "multiset" in Kotl...
# announcements
a
is there a good equivalent of a "multiset" in Kotlin? I don't care about order. I simply care about element count and I want to compare equality between to multisets.
i.e.,
[1,4,4,7] == [7,4,1,4]
t
You could easily implement this with a extension function
s
I don’t believe this is available in the stdlib
a
alright, I'll just implement my own then
wait... I could probably just compare groupings
👆 1
a
What language does
multiset
come from? How does it differ from a
set
?
Copy code
setOf(1, 4, 4, 7) == setOf(7, 4, 1, 4)
s
@Alan Evans I’ve seen it in C++, Google provides it for the JVM with Guava
it differs by allowing multiple instances of the same element
a
right, so
multiSetOf(1, 4, 4, 7) != multiSetOf(7, 4, 1, 1)
?
s
right
262 Views