Crate more_collections
source ·Expand description
More collection types.
§Small* collections
Built on top of the excellent smallvec
crate, SmallMap
and SmallSet
are a Map
and Set
respectively that
are inlined if they contain fewer values than a (statically chosen)
capacity C
, otherwise they are heap allocated and backed by an
IndexMap
.
§VecMap
See vec_map
for more details.
§Multimap
A collection that maps keys to values, similar to HashMap
, but where
each key may be associated with multiple values. Multimaps can be
visualized as a map from keys to non-empty collections of values:
- a → 0, 1
- b → 2
Or, it can be visualized as a collection of key-value pairs:
- a → 0
- a → 1
- b → 2
The multimap API is based on the second form, len() == 3
and keys_len() == 2
for the above example.
Name | Behaves as | Keys order | Values order | May contain duplicates |
---|---|---|---|---|
HashSetMultimap | HashMap <K, HashSet <V>> | Arbitrary order | Arbitrary order | No |
HashVecMultimap | HashMap <K, Vec <V>> | Arbitrary order | Insertion order1 | Yes |
IndexSetMultimap | IndexMap <K, IndexSet <V>> | Insertion order1 | Insertion order1 | No |
IndexVecMultimap | IndexMap <K, Vec <V>> | Insertion order1 | Insertion order1 | Yes |
§Crate features
All features are disabled by default. The options are:
hashsetmultimap
hashvecmultimap
indexsetmultimap
indexvecmultimap
Re-exports§
pub use small_map::SmallMap;
pub use small_set::SmallSet;
pub use vec_map::IndexKey;
pub use vec_map::VecMap;
Modules§
Macros§
- Creates
SmallMap
with inline capacity equal to the number of values. - Create a
SmallSet
with with the specified values. - Create a
SmallSet
with inline capacity equal to the number of values. - Create a
VecMap
containing the arguments.
Structs§
- Multimap implementation that behaves like
HashMap<K, HashSet<V>>
. - Multimap implementation that behaves like
HashMap<K, Vec<V>>
. - Multimap implementation that behaves like
IndexMap<K, IndexSet<V>>
. - Multimap implementation that behaves like
IndexMap<K, Vec<V>>
.