Crate hashbag

source ·
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§

  • An draining iterator over the distinct items of a HashBag and their occurrence counts.
  • A view into a single entry in the bag, which may either be vacant or occupied. This enum is constructed from the entry method on HashBag
  • A hash bag implemented as a HashMap where the value is usize.
  • An owning iterator over the distinct items of a HashBag and their occurrence counts.
  • An iterator over the items of a HashBag.
  • An iterator over the distinct items of a HashBag and their occurrence counts.