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

Method insert

code/chapter09/bloom_filter.rs:35–41  ·  view source on GitHub ↗

按照 hash_fn_count 计算值并置比特桶相应位为 true

(&mut self, elem: &T)

Source from the content-addressed store, hash-verified

33
34 // 按照 hash_fn_count 计算值并置比特桶相应位为 true
35 fn insert(&mut self, elem: &T) {
36 let hashes = self.make_hash(elem);
37 for fn_i in 0..self.hash_fn_count {
38 let index = self.get_index(hashes, fn_i as u64);
39 self.bits[index] = true;
40 }
41 }
42
43 // 数据查询
44 fn contains(&self, elem: &T) -> bool {

Callers 1

mainFunction · 0.45

Calls 2

make_hashMethod · 0.45
get_indexMethod · 0.45

Tested by

no test coverage detected