Skip to main content

Module double_map

Module double_map 

Source
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§

DoubleMap
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.
IntoIter
An owning iterator over the entries of a DoubleMap, yielding (K1, K2, V) triples.
IntoKeys
A consuming iterator over the keys of a DoubleMap, yielding owned (K1, K2) tuples.
IntoValues
A consuming iterator over the values of a DoubleMap, yielding owned V.
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.
OccupiedEntry
A view into an occupied entry of a DoubleMap.
TryReserveError
The error type for try_reserve methods.
VacantEntry
A view into a vacant entry of a DoubleMap.
Values
A borrowing iterator over the values of a DoubleMap, yielding &'a V.
ValuesMut
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.
KeyConflictError
Error returned by DoubleMap::insert and DoubleMap::entry when one or both of the supplied keys clash with an existing entry in the map.