Expand description
An unordered multiset/bag implementation backed by HashMap.
A bag, unlike a set, allows duplicate values, and keeps track of how many
duplicates each value holds. This type of collection is often referred to
as an unordered multiset (see also C++’s std::unordered_multiset).
This multiset/bag is implemented using a HashMap<T, usize> and so requires
that the stored type implements Hash + Eq.
For usage examples, see the primary type HashBag.
If you want to use a hash table with amortized resizes,
set the amortize feature.
(De)serialization via serde is also available with the serde feature.
Deserialization note: if the incoming data contains two instances of T that are the same, the resulting HashBag will merge
the counts of those instances.
Structs§
- Drain
- An draining iterator over the distinct items of a
HashBagand their occurrence counts. - Entry
- A view into a single entry in the bag, which may either be vacant or occupied.
This
enumis constructed from theentrymethod onHashBag - HashBag
- A hash bag implemented as a
HashMapwhere the value isusize. - Into
Iter - An owning iterator over the distinct items of a
HashBagand their occurrence counts. - Iter
- An iterator over the items of a
HashBag. - SetIter
- An iterator over the distinct items of a
HashBagand their occurrence counts.