At least 5x faster alternative of HashMap
, for very small maps. It is also faster than FxHashMap, hashbrown, ArrayMap, and nohash-hasher. The smaller the map, the higher the performance. When the map contains more than 50 keys, it is better to use the standard HashMap
, since the performance of micromap::Map
may start to degrade.
The only important restriction is that both key and value must implement the Copy
trait.
WELCOME: Not all functions that a user expects to have in a map are implemented. I will appreciate if you contribute by implementing these missing functions.
Here is how you use it:
use micromap::Map;
let mut m : Map<u64, &str, 10> = Map::new(); // allocation on stack
m.insert(1, "foo");
m.insert(2, "bar");
assert_eq!(2, m.len());
Pay attention, here the map is created with an extra generic argument 10
. This is the total size of the map, which is allocated on stack when ::new()
is called. Unlike HashMap
, the Map
doesn't use heap at all. If more than ten keys will be added to the map, it will panic.
Read the API documentation. The struct micromap::Map
is designed as closely similar to std::collections::HashMap
as possible.
How to Contribute
First, install Rust and then:
$ cargo test -vv
If everything goes well, fork repository, make changes, send us a pull request. We will review your changes and apply them to the master
branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run cargo test
again. Also, run cargo fmt
and cargo clippy
.