Crate micromap

Source
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.
IntoIter
Into-iterator over the Map.
IntoKeys
Consuming iterator over the keys of the Map.
IntoValues
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.
OccupiedEntry
A view into an occupied entry in a Map. It is part of the Entry enum.
Set
A faster alternative of std::collections::HashSet.
SetDrain
SetIntoIter
Into-iterator over the Set.
SetIter
Iterator over the Set.
VacantEntry
A view into a vacant entry in a Map. It is part of the Entry enum.
Values
An iterator over the values of the Map.
ValuesMut
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.