use crate::bloom_sol::struct_def::CountingBloomFilter;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
impl CountingBloomFilter {
/// Computes the hash indices for a given item.
pub fn get_hash_indices<T: Hash>(&self, item: &T) -> Vec<usize> {
(0..self.num_hashes)
.map(|i| {
let mut hasher = DefaultHasher::new();
item.hash(&mut hasher);
// Seed with the hash index to simulate multiple hash functions.
hasher.write_u32(i as u32);
(hasher.finish() % self.size as u64) as usize
})
.collect()
}
}