pub struct HyperLogLog<S = DefaultHasher> { /* private fields */ }
Expand description
HyperLogLog is a data structure for the “count-distinct problem”, approximating the number of distinct elements in a multiset.
§Example
use hyperloglockless::HyperLogLog;
let hll = HyperLogLog::new(16);
hll.insert("42");
hll.insert("🦀");
let count = hll.count();
Implementations§
Source§impl HyperLogLog
impl HyperLogLog
Source§impl<S: BuildHasher> HyperLogLog<S>
impl<S: BuildHasher> HyperLogLog<S>
Sourcepub fn with_hasher(precision: u8, hasher: S) -> Self
pub fn with_hasher(precision: u8, hasher: S) -> Self
Returns a new HyperLogLog
with 1 << precision
registers (1 byte each)
using the provided hasher.
Sourcepub fn iter(&self) -> impl Iterator<Item = u8> + use<'_, S>
pub fn iter(&self) -> impl Iterator<Item = u8> + use<'_, S>
Returns an iterator over the value of each register.
Sourcepub fn insert_hash(&self, hash: u64)
pub fn insert_hash(&self, hash: u64)
Inserts the hash of an item into the HyperLogLog
.
Trait Implementations§
Source§impl<S: Debug> Debug for HyperLogLog<S>
impl<S: Debug> Debug for HyperLogLog<S>
Source§impl<T: Hash, S: BuildHasher> Extend<T> for HyperLogLog<S>
impl<T: Hash, S: BuildHasher> Extend<T> for HyperLogLog<S>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<S: BuildHasher> PartialEq for HyperLogLog<S>
impl<S: BuildHasher> PartialEq for HyperLogLog<S>
impl<S: BuildHasher> Eq for HyperLogLog<S>
Auto Trait Implementations§
impl<S> Freeze for HyperLogLog<S>where
S: Freeze,
impl<S> RefUnwindSafe for HyperLogLog<S>where
S: RefUnwindSafe,
impl<S> Send for HyperLogLog<S>where
S: Send,
impl<S> Sync for HyperLogLog<S>where
S: Sync,
impl<S> Unpin for HyperLogLog<S>where
S: Unpin,
impl<S> UnwindSafe for HyperLogLog<S>where
S: UnwindSafe,
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