12 releases
Uses old Rust 2015
0.3.2 | Aug 6, 2018 |
---|---|
0.3.1 | Jul 28, 2018 |
0.2.8 | Jan 22, 2018 |
0.2.6 | May 10, 2017 |
0.1.0 | Dec 25, 2016 |
#2137 in Algorithms
8,439 downloads per month
Used in 26 crates
(via fasthash)
1MB
28K
SLoC
Contains (ELF exe/lib, 2KB) src/smhasher/fhtw-elf64.o, (ELF exe/lib, 2KB) src/smhasher/falkhash-elf64.o, (Mach-o exe, 1KB) src/smhasher/falkhash-macho64.o, (Mach-o exe, 2KB) src/smhasher/fhtw-macho64.o
rust-fasthash
A suite of non-cryptographic hash functions for Rust, binding the smhasher.
Usage
[dependencies]
fasthash = "0.4"
hash
and hash_with_seed
function
use fasthash::*;
let h = city::hash64("hello world");
let h = metro::hash64_with_seed("hello world", 123);
std::hash::Hash
use std::hash::{Hash, Hasher};
use fasthash::{MetroHasher, FastHasher};
fn hash<T: Hash>(t: &T) -> u64 {
// Or use any of the `*Hasher` struct's available as aliases from
// root or in their respective modules as Hasher32/64 and some 128.
let mut s = MetroHasher::default();
t.hash(&mut s);
s.finish()
}
hash(&"hello world");
HashMap
and HashSet
use std::collections::HashSet;
use fasthash::spooky::Hash128;
let mut set = HashSet::with_hasher(Hash128);
set.insert(2);
RandomState
use std::collections::HashMap;
use fasthash::RandomState;
use fasthash::city::Hash64;
let s = RandomState::<Hash64>::new();
let mut map = HashMap::with_hasher(s);
assert_eq!(map.insert(37, "a"), None);
assert_eq!(map.is_empty(), false);
map.insert(37, "b");
assert_eq!(map.insert(37, "c"), Some("b"));
assert_eq!(map[&37], "c");
Hash Functions
- Modern Hash Functions
- City Hash
- Farm Hash
- Highway Hash
- Komi Hash new
- Lookup3
- Meow Hash new
- Metro Hash
- Mum Hash
- Murmur Hash
- mx3 Hash new
- NmHash new
- PengyHash new
- PrvHash new
- Sea Hash
- Spooky Hash
- T1ha Hash
- Umash new
- wyhash (final3)
- xx Hash with experimental XXH3 hash algorithm
- Compatibility
Benchmark
First install cargo-criterion:
$ cargo install cargo-criterion
Then you can use it to run Criterion-rs
benchmarks:
$ cargo criterion