bloom-sol 0.0.3

Counting bloom filter, aimed for solana
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::bloom_sol::struct_def::CountingBloomFilter;
use std::hash::Hash;

impl CountingBloomFilter {
    /// Checks if an item might be in the filter.
    ///
    /// Returns `true` if the item is possibly present (may be false positive), `false` if definitely not present.
    pub fn contains<T: Hash>(&self, item: &T) -> bool {
        self.get_hash_indices(item)
            .iter()
            .all(|&index| self.counters[index] > 0)
    }
}