pithanos 0.2.0

Fast, lock-free probabilistic data structures for modern Rust.
Documentation
use std::hash::Hash;

/// A structure that supports probabilistic membership queries.
pub trait ProbabilisticSet {
    /// Insert an item.
    fn insert<T: Hash>(&self, item: &T) -> bool;

    /// Check if an item is *probably* in the set.
    fn contains<T: Hash>(&self, item: &T) -> bool;

    /// Delete an item. Hash collision in deletion may lead to false negatives.
    fn delete<T: Hash>(&self, _item: &T);
}

/// A structure that supports approximate frequency counting.
pub trait FrequencySketch {
    /// Increment the count for a given item by `count`.
    fn increment<T: Hash>(&self, item: &T, count: u32);

    /// Estimate the frequency of a given item.
    fn frequency<T: Hash>(&self, item: &T) -> u32;
}