Debian Codegraph @

/

debian rust-intmap 2.0.0-1debian librust-intmap-dev debian librust-intmap+default-dev debian librust-intmap+serde-dev debian librust-intmap-2-dev debian librust-intmap-2+default-dev debian librust-intmap-2+serde-dev debian librust-intmap-2.0-dev debian librust-intmap-2.0+default-dev debian librust-intmap-2.0+serde-dev debian librust-intmap-2.0.0-dev debian librust-intmap-2.0.0+default-dev debian librust-intmap-2.0.0+serde-dev cargo intmap 2.0.0 debianjsonmakefilemarkdownrustrust-c-abishelltomlyaml 21 files · 328 symbols
View dependency graph

Depends on

  • debhelper (debhelper)
  • dh-cargo (dh-cargo)
  • cargo, librust-serde-1-dev, libstd-rust-dev, rustc
README (full)

crates.io

rust-intmap

Specialized hashmap for u64 keys

Might be missing some functionality but you can remove, add, get and clear for now.

Be aware that no effort is made against DoS attacks.

Performace compared to the standard hashmap:

test tests::u64_get_built_in    ... bench:      22,320 ns/iter (+/- 446)
test tests::u64_get_intmap      ... bench:       2,959 ns/iter (+/- 148)
test tests::u64_insert_built_in ... bench:      27,666 ns/iter (+/- 1,230)
test tests::u64_insert_intmap   ... bench:      14,047 ns/iter (+/- 1,461)

Breaking Changes

2.0.0 - Changed behavior of insert to match std::HashMap. The old behavior is renamed to insert_checked.

How to use

Simple example.

extern crate intmap;

use intmap::IntMap;

let mut map = IntMap::new();

for i in 0..20_000 {
    map.insert(i, format!("item: {:?}", i));
}

How can it be so much faster?

I use a specialized hash function for u64 it multiplies the key with the largest prime for u64. By keeping the internal cache a power 2 you can avoid the expensive modulus operator as per http://stackoverflow.com/questions/6670715/mod-of-power-2-on-bitwise-operators.

#[inline]
fn hash_u64(seed: u64) -> u64 {
    let a = 11400714819323198549u64;
    let val = a.wrapping_mul(seed);
    val
}
dir .github/
dir benches/
dir debian/
dir src/
dir tests/
file .cargo_vcs_info.json
file .gitignore
file CHANGELOG.md
file Cargo.toml
file Cargo.toml.orig
file LICENSE-MIT
file README.md