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

Method contains

publication/code/chapter10/bloom_filter.rs:46–52  ·  view source on GitHub ↗

数据查询

(&self, elem: &T)

Source from the content-addressed store, hash-verified

44
45 // 数据查询
46 fn contains(&self, elem: &T) -> bool {
47 let hashes = self.make_hash(elem);
48 (0..self.hash_fn_count).all(|fn_i| {
49 let index = self.get_index(hashes, fn_i as u64);
50 self.bits[index]
51 })
52 }
53
54 // 计算哈希
55 fn make_hash(&self, elem: &T) -> (u64, u64) {

Callers 1

mainFunction · 0.45

Calls 2

make_hashMethod · 0.45
get_indexMethod · 0.45

Tested by

no test coverage detected