At least 5x faster alternative of HashMap
,
for very small maps. It is also faster than
FxHashMap,
ArrayMap. The smaller the map, the higher the
performance. When the map is larger than 50, it is better to use 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:
rust
use micromap::Map;
let mut m : Map<u64, &str, 10> = Map::new();
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.
Read the API documentation. The struct
micromap::Map
is designed as closely similar to
std::collections::HashMap
as possible.
First, install Rust and then:
bash
$ 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
.