Trait hyperloglog_rs::iter::HyperLogLogIterator
source · pub trait HyperLogLogIterator<const PRECISION: usize, const BITS: usize> {
// Required method
fn union(self) -> HyperLogLog<PRECISION, BITS>;
}
Required Methods§
sourcefn union(self) -> HyperLogLog<PRECISION, BITS>
fn union(self) -> HyperLogLog<PRECISION, BITS>
Returns a HyperLogLog that is the union of all HyperLogLogs in the iterator.
Example
use hyperloglog_rs::prelude::*;
let mut hll1 = HyperLogLog::<12, 6>::new();
hll1.insert(&1);
hll1.insert(&2);
let mut hll2 = HyperLogLog::<12, 6>::new();
hll2.insert(&3);
hll2.insert(&4);
let mut hll3 = HyperLogLog::<12, 6>::new();
hll3.insert(&5);
hll3.insert(&6);
let hll_union = vec![hll1, hll2, hll3].iter().union();
assert!(hll_union.estimate_cardinality() - 6.0 < 1.0, "Expected 6.0, got {}", hll_union.estimate_cardinality());