pub struct AtomicHyperLogLog<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.
AtomicHyperLogLog is the thread-safe counterpart of HyperLogLog.
§Example
use hyperloglockless::AtomicHyperLogLog;
let hll = AtomicHyperLogLog::new(16);
hll.insert("42");
hll.insert("🦀");
let count = hll.count();Implementations§
Source§impl<S: BuildHasher> AtomicHyperLogLog<S>
impl<S: BuildHasher> AtomicHyperLogLog<S>
Sourcepub fn with_hasher(precision: u8, hasher: S) -> Self
pub fn with_hasher(precision: u8, hasher: S) -> Self
Returns a new AtomicHyperLogLog with 1 << precision registers (1 byte each)
using the provided hasher.
Source§impl AtomicHyperLogLog
impl AtomicHyperLogLog
Sourcepub fn new(precision: u8) -> AtomicHyperLogLog<DefaultHasher>
pub fn new(precision: u8) -> AtomicHyperLogLog<DefaultHasher>
Returns a new Self with 1 << precision registers (1 byte each)
using the default hasher with a random seed.
Sourcepub fn seeded(precision: u8, seed: u128) -> AtomicHyperLogLog<DefaultHasher>
pub fn seeded(precision: u8, seed: u128) -> AtomicHyperLogLog<DefaultHasher>
Returns a new Self with 1 << precision registers (1 byte each)
using the default hasher seeded with seed.
Source§impl<S: BuildHasher> AtomicHyperLogLog<S>
impl<S: BuildHasher> AtomicHyperLogLog<S>
Source§impl<S: BuildHasher> AtomicHyperLogLog<S>
impl<S: BuildHasher> AtomicHyperLogLog<S>
Sourcepub fn iter(&self) -> impl Iterator<Item = u8> + '_
pub fn iter(&self) -> impl Iterator<Item = u8> + '_
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.
Sourcepub fn insert_all<T: Hash, I: IntoIterator<Item = T>>(&self, iter: I)
pub fn insert_all<T: Hash, I: IntoIterator<Item = T>>(&self, iter: I)
Inserts all the items in iter into the self. Immutable version of Self::extend.
Trait Implementations§
Source§impl<S: BuildHasher + Clone> Clone for AtomicHyperLogLog<S>
impl<S: BuildHasher + Clone> Clone for AtomicHyperLogLog<S>
Source§impl<S: Debug> Debug for AtomicHyperLogLog<S>
impl<S: Debug> Debug for AtomicHyperLogLog<S>
Source§impl<T: Hash, S: BuildHasher> Extend<T> for AtomicHyperLogLog<S>
impl<T: Hash, S: BuildHasher> Extend<T> for AtomicHyperLogLog<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 AtomicHyperLogLog<S>
impl<S: BuildHasher> PartialEq for AtomicHyperLogLog<S>
impl<S: BuildHasher> Eq for AtomicHyperLogLog<S>
Auto Trait Implementations§
impl<S = CloneBuildHasher<RandomDefaultHasher>> !Freeze for AtomicHyperLogLog<S>
impl<S> RefUnwindSafe for AtomicHyperLogLog<S>where
S: RefUnwindSafe,
impl<S> Send for AtomicHyperLogLog<S>where
S: Send,
impl<S> Sync for AtomicHyperLogLog<S>where
S: Sync,
impl<S> Unpin for AtomicHyperLogLog<S>where
S: Unpin,
impl<S> UnwindSafe for AtomicHyperLogLog<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