flat_multimap/
lib.rs

1//! A multimap and multiset implementation using a flattened hash table.
2//!
3//! ---
4//!
5//! [`FlatMultimap`] is a [multimap](https://en.wikipedia.org/wiki/Multimap)
6//! implementation where entries are stored as a flattened hash map:
7//!  - `a -> 1`
8//!  - `a -> 2`
9//!  - `b -> 3`
10//!
11//! as opposed to the common implementation using a hash map
12//! which maps keys to a collection of values:
13//!  - `a -> 1, 2`
14//!  - `b -> 3`
15//!
16//! ---
17//!
18//! [`FlatMultiset`] is a [multiset](https://en.wikipedia.org/wiki/Multiset)
19//! implementation where items are stored as a flattened hash set:
20//!  - `a`
21//!  - `a`
22//!  - `b`
23//!
24//! as opposed to the common implementation using a hash map
25//! which maps items to a variable counting the number of occurances:
26//!  - `a -> 2`
27//!  - `b -> 1`
28//!
29//! ---
30//!
31//! Storing elements as a flattened hash table ***can*** have the benefit
32//! that it saves space compared to the common implementations.
33//! This ***can*** be the case when there are very few duplicates and/or the size of the elements is very small.
34//!
35//! Disadvantages of storing elements this way compared to the common implementations is that much
36//! more space is required when there are many duplicates. Furthermore, there are no efficient operations which can
37//! get all the values associated with a single key (in the case of a map), and no efficient operations to count the number
38//! of duplicates.
39
40/// Multimap implementation where entries are stored as a flattened hash map.
41pub mod map;
42
43/// Multiset implementation where items are stored as a flattened hash set.
44pub mod set;
45
46#[cfg(feature = "rayon")]
47mod rayon;
48
49#[cfg(feature = "serde")]
50mod serde;
51
52pub use hashbrown::TryReserveError;
53pub use map::FlatMultimap;
54pub use set::FlatMultiset;