A Rimbu MultiSet is an immutable Set-like structure where each unique element can be added multiple times. Each element in the MultiSet occurs one or more times. The MultiSet keeps track of the amount of times an element was added.
When to use
The MultiSet is useful for use cases that involve some kind of frequency count. For example, for a piece of text, to split it in words and count the amount of times each word occurs. Or, for a set of events, to count the frequencies of those events.
MultiSet<T> is implemented on top of an
RMap<T, number> map. The
.countMap property provides direct access to this map, and sometimes may have more convenient ways to access information about the contained data.
@rimbu/core package exports the following abstract MultiSet TypeScript types:
|a type-variant MultiSet with elements of type T
|a generic MultiSet with elements of type T
@rimbu/core package exports the following concrete Multiset types:
|a MultiSet with hashed elements of type T
|a MultiSet with sorted elements of type T