pub struct Hll8(/* private fields */);
Expand description
HyperLogLog approximate counting mechanism
This uses a fixed set of 256 buckets (k=8, M=256), each holding a count up to 255. https://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf
This is used for NIP-45 PR #1561
Implementations§
source§impl Hll8
impl Hll8
sourcepub fn to_hex_string(&self) -> String
pub fn to_hex_string(&self) -> String
Export to a (hex) string
sourcepub fn add_element(
&mut self,
input: &[u8; 32],
offset: usize,
) -> Result<(), Error>
pub fn add_element( &mut self, input: &[u8; 32], offset: usize, ) -> Result<(), Error>
Add an element to the count by value Returns false on error (e.g. offset is out of range)
sourcepub fn add_element_inner(&mut self, index: u8, rho: u8)
pub fn add_element_inner(&mut self, index: u8, rho: u8)
Add an element to the count by index and rho (position of the first 1)
sourcepub fn estimate_count(&self) -> usize
pub fn estimate_count(&self) -> usize
Compute the approximate count
Trait Implementations§
source§impl AddAssign for Hll8
impl AddAssign for Hll8
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+=
operation. Read moreimpl Copy for Hll8
Auto Trait Implementations§
impl Freeze for Hll8
impl RefUnwindSafe for Hll8
impl Send for Hll8
impl Sync for Hll8
impl Unpin for Hll8
impl UnwindSafe for Hll8
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)