Crates.io | t1ha |
lib.rs | t1ha |
version | 0.1.2 |
source | src |
created_at | 2019-03-07 09:06:32.315617 |
updated_at | 2024-02-19 10:13:30.031182 |
description | An implementation of the T1AH (Fast Positive Hash) hash function. |
homepage | https://github.com/flier/rust-t1ha |
repository | https://github.com/flier/rust-t1ha |
max_upload_size | |
id | 119294 |
size | 100,229 |
An implementation of the T1HA (Fast Positive Hash) hash function.
To include this crate in your program, add the following to your Cargo.toml
:
[dependencies]
t1ha = "0.1"
t1ha
in a HashMap
The T1haHashMap
type alias is the easiest way to use the standard library’s HashMap
with t1ha
.
use t1ha::T1haHashMap;
let mut map = T1haHashMap::default();
map.insert(1, "one");
map.insert(2, "two");
map = T1haHashMap::with_capacity_and_hasher(10, Default::default());
map.insert(1, "one");
map.insert(2, "two");
Note: the standard library’s HashMap::new
and HashMap::with_capacity
are only implemented for the RandomState
hasher, so using Default
to get the hasher is the next best option.
t1ha
in a HashSet
Similarly, T1haHashSet
is a type alias for the standard library’s HashSet
with `t1ha.
use t1ha::T1haHashSet;
let mut set = T1haHashSet::default();
set.insert(1);
set.insert(2);
set = T1haHashSet::with_capacity_and_hasher(10, Default::default());
set.insert(1);
set.insert(2);
t1ha
can use AES, AVX or AVX2 instructions as hardware acceleration.
Implementation | Platform/CPU |
---|---|
t1ha0_ia32aes_avx() |
x86 with AES-NI and AVX extensions |
t1ha0_ia32aes_avx2() |
x86 with AES-NI and AVX2 extensions |
t1ha0_ia32aes_noavx() |
x86 with AES-NI without AVX extensions |
t1ha0_32le() |
32-bit little-endian |
t1h0a_32be() |
32-bit big-endian |
t1ha1_le() |
64-bit little-endian |
t1ha1_be() |
64-bit big-endian |
t1ha2_atonce() |
64-bit little-endian |
You could choose the right implementation base on your target_cpu
.
$ RUSTFLAGS="-C target-cpu=native" cargo build
rust-t1ha
provide a rough performance comparison to other Rust
implemenation of non-cryptographic hash functions, you can run the benchmark base on your envrionment and usage scenario.
$ RUSTFLAGS="-C target-cpu=native" cargo bench
t1ha
Libraryrust-t1ha
major focus Rust
implementation, if you intent to use the origin native t1ha
library, please check rust-fasthash project and it's benchmark, which provides a suite of non-cryptographic hash functions from SMHasher.