Skip to main content

Crate multiset

Crate multiset 

Source
Expand description

A multiset that allows multiple occurrences of the same element.

Backed by a std::collections::BTreeMap, so elements are kept in sorted order by key. BTreeMap is preferred over HashMap here to avoid collision blowups and to allow O(log n) first / last queries.

All operations are O(log n); len and is_empty are O(n) (they sum all counts) but can be cached if needed.

Structsยง

MultiSet
A multiset of values of type T (any Ord + Clone).