Crate more_collections

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.

NameBehaves asKeys orderValues orderMay contain duplicates
HashSetMultimapHashMap<K,HashSet<V>>Arbitrary orderArbitrary orderNo
HashVecMultimapHashMap<K,Vec<V>>Arbitrary orderInsertion order1Yes
IndexSetMultimapIndexMap<K,IndexSet<V>>Insertion order1Insertion order1No
IndexVecMultimapIndexMap<K, Vec<V>>Insertion order1Insertion order1Yes

§Crate features

All features are disabled by default. The options are:

  • hashsetmultimap
  • hashvecmultimap
  • indexsetmultimap
  • indexvecmultimap

  1. Insertion order is preserved, unless remove() or swap_remove() is called. See more in the IndexMap documentation. ↩ 1 2 3 4 5

Re-exports§

pub use small_map::SmallMap;
pub use small_set::SmallSet;
pub use vec_map::IndexKey;
pub use vec_map::VecMap;

Modules§

hash_set_multimap
hash_vec_multimap
index_set_multimap
index_vec_multimap
small_map
small_set
vec_map
VecMap is a Vec-backed map, for faster random access.

Macros§

hashsetmultimap
hashvecmultimap
indexsetmultimap
indexvecmultimap
smallmap
smallmap_inline
Creates SmallMap with inline capacity equal to the number of values.
smallset
Create a SmallSet with with the specified values.
smallset_inline
Create a SmallSet with inline capacity equal to the number of values.
vecmap
Create a VecMap containing the arguments.

Structs§

HashSetMultimap
Multimap implementation that behaves like HashMap<K, HashSet<V>>.
HashVecMultimap
Multimap implementation that behaves like HashMap<K, Vec<V>>.
IndexSetMultimap
Multimap implementation that behaves like IndexMap<K, IndexSet<V>>.
IndexVecMultimap
Multimap implementation that behaves like IndexMap<K, Vec<V>>.