Expand description
A map-like container supporting lookup by two independent key types.
DoubleMap keeps two internal HashMaps: one owns the value (keyed by K1)
and the other is an index from K2 to K1. Lookups by either key type are
O(1), and insertions, removals, and clears keep the two maps in sync.
The public API mirrors std::collections::HashMap as closely as possible, with
key-centric methods (get, contains, remove, …) split into _by_key1 and
_by_key2 variants.
Structs§
- Double
Map - A map-like container supporting
O(1)lookup by two key types. - Drain
- A draining iterator over the entries of a
DoubleMap, yielding(K1, K2, V)triples while emptying the map in place. - Into
Iter - An owning iterator over the entries of a
DoubleMap, yielding(K1, K2, V)triples. - Into
Keys - A consuming iterator over the keys of a
DoubleMap, yielding owned(K1, K2)tuples. - Into
Values - A consuming iterator over the values of a
DoubleMap, yielding ownedV. - Iter
- A borrowing iterator over the entries of a
DoubleMap, yielding(&'a K1, &'a K2, &'a V)triples. - IterMut
- A mutably borrowing iterator over the entries of a
DoubleMap, yielding(&'a K1, &'a K2, &'a mut V)triples. - Keys
- A borrowing iterator over the keys of a
DoubleMap, yielding(&'a K1, &'a K2)tuples. - Occupied
Entry - A view into an occupied entry of a
DoubleMap. - TryReserve
Error - The error type for
try_reservemethods. - Vacant
Entry - A view into a vacant entry of a
DoubleMap. - Values
- A borrowing iterator over the values of a
DoubleMap, yielding&'a V. - Values
Mut - A mutably borrowing iterator over the values of a
DoubleMap, yielding&'a mut V.
Enums§
- Entry
- A view into a single entry in a
DoubleMap, which may be either vacant or occupied. - KeyConflict
Error - Error returned by
DoubleMap::insertandDoubleMap::entrywhen one or both of the supplied keys clash with an existing entry in the map.