Expand description
This is a simpler and faster alternative implementation of the standard HashMap
.
It doesn’t use heap and doesn’t use hashing at all. It simply keeps all key-value
pairs in an array and when it’s necessary to retrieve by key, it scrolls through
the entire array. This implementation works much faster for small maps of
less than 50 keys, but definitely is not suitable for larger maps.
Check this page for the recent benchmarking results.
For example, here is how a map with a few keys can be created:
use micromap::Map;
let mut m : Map<u64, &str, 10> = Map::new();
m.insert(1, "Hello, world!");
m.insert(2, "Good bye!");
assert_eq!(2, m.len());
Creating a Map
requires knowing the maximum size of it, upfront. This is
what the third type argument 10
is for, in the example above. The array
will have exactly ten elements. An attempt to add an 11th element will lead
to a panic.
Structs§
- Drain
- A draining iterator over the entries of a
Map
. - Into
Iter - Into-iterator over the
Map
. - Into
Keys - Consuming iterator over the keys of the
Map
. - Into
Values - Consuming iterator over the values of the
Map
. - Iter
- Iterator over the
Map
. - IterMut
- Mutable Iterator over the
Map
. - Keys
- A read-only iterator over the keys of the
Map
. - Map
- A faster alternative of
std::collections::HashMap
. - Occupied
Entry - A view into an occupied entry in a
Map
. It is part of theEntry
enum. - Set
- A faster alternative of
std::collections::HashSet
. - SetDrain
- SetInto
Iter - Into-iterator over the
Set
. - SetIter
- Iterator over the
Set
. - Vacant
Entry - A view into a vacant entry in a
Map
. It is part of theEntry
enum. - Values
- An iterator over the values of the
Map
. - Values
Mut - Mutable iterator over the values of the
Map
.
Enums§
- Entry
- A view into a single entry in a map, which may either be vacant or occupied.