#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
#[cfg(not(feature = "std"))]
extern crate alloc;
pub mod bloom;
pub mod countmin;
pub mod hash;
pub mod hyperloglog;
pub use bloom::BloomFilter;
pub use countmin::CountMinSketch;
pub use hyperloglog::HyperLogLog;
pub mod traits {
use core::hash::Hash;
pub trait MembershipSketch<T: Hash> {
fn insert(&mut self, item: &T);
fn contains(&self, item: &T) -> bool;
fn false_positive_rate(&self) -> f64;
fn len(&self) -> usize;
fn is_empty(&self) -> bool {
self.len() == 0
}
fn clear(&mut self);
}
pub trait CardinalitySketch<T: Hash> {
fn insert(&mut self, item: &T);
fn count(&self) -> u64;
fn std_error(&self) -> f64;
fn merge(&mut self, other: &Self);
fn clear(&mut self);
}
pub trait FrequencySketch<T: Hash> {
fn insert(&mut self, item: &T);
fn insert_many(&mut self, item: &T, count: u64);
fn estimate(&self, item: &T) -> u64;
fn error_rate(&self) -> f64;
fn confidence(&self) -> f64;
fn total(&self) -> u64;
fn clear(&mut self);
}
}
pub mod prelude {
pub use crate::bloom::BloomFilter;
pub use crate::countmin::CountMinSketch;
pub use crate::hyperloglog::HyperLogLog;
pub use crate::traits::{CardinalitySketch, FrequencySketch, MembershipSketch};
}