#hash #hashing #suite #non-cryptographic #function #fasthash

sys fasthash-sys

Rust 非加密散列函数套件

12 个版本

使用旧的 Rust 2015

0.3.2 2018 年 8 月 6 日
0.3.1 2018 年 7 月 28 日
0.2.8 2018 年 1 月 22 日
0.2.6 2017 年 5 月 10 日
0.1.0 2016 年 12 月 25 日

#2075 in 算法

Download history 1796/week @ 2024-03-14 2226/week @ 2024-03-21 2364/week @ 2024-03-28 2103/week @ 2024-04-04 2173/week @ 2024-04-11 2009/week @ 2024-04-18 1735/week @ 2024-04-25 1937/week @ 2024-05-02 2205/week @ 2024-05-09 2117/week @ 2024-05-16 2129/week @ 2024-05-23 2214/week @ 2024-05-30 2154/week @ 2024-06-06 2598/week @ 2024-06-13 2647/week @ 2024-06-20 1832/week @ 2024-06-27

9,719 每月下载量
26 个 crate 中使用 (通过 fasthash)

Apache-2.0

1MB
28K SLoC

C++ 17K SLoC // 0.1% comments C 8K SLoC // 0.2% comments Rust 1.5K SLoC // 0.0% comments Visual Studio Project 1K SLoC Assembly 307 SLoC // 0.3% comments Visual Studio Solution 63 SLoC Shell 32 SLoC // 0.2% comments Batch 18 SLoC Perl 11 SLoC // 0.2% comments

包含 (ELF 可执行文件/库, 2KB) src/smhasher/fhtw-elf64.o, (ELF 可执行文件/库, 2KB) src/smhasher/falkhash-elf64.o, (Mach-o 可执行文件, 1KB) src/smhasher/falkhash-macho64.o, (Mach-o 可执行文件, 2KB) src/smhasher/fhtw-macho64.o

rust-fasthash 持续集成 crate docs

Rust 非加密散列函数套件,绑定 smhasher.

用法

[dependencies]
fasthash = "0.4"

hashhash_with_seed 函数

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");

HashMapHashSet

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");

散列函数

基准测试

首先安装 cargo-criterion

$ cargo install cargo-criterion

然后您可以使用它来运行 Criterion-rs 基准测试

$ cargo criterion

依赖项