MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / BloomFilter

Class BloomFilter

publication/code/chapter10/bloom_filter.rs:8–13  ·  view source on GitHub ↗

布隆过滤器

Source from the content-addressed store, hash-verified

6
7// 布隆过滤器
8struct BloomFilter<T: ?Sized> {
9 bits: Vec<bool>, // 比特桶
10 hash_fn_count: usize, // 哈希函数个数
11 hashers: [DefaultHasher; 2], // 两个哈希函数
12 _phantom: PhantomData<T>, // T 占位,欺骗编译器
13}
14
15impl<T: ?Sized + Hash> BloomFilter<T> {
16 fn new(cap: usize, ert: f64) -> Self {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected