pub trait HyperLogLogIterator<P: Precision + WordType<BITS>, const BITS: usize> {
// Required method
fn union(self) -> HyperLogLog<P, BITS>;
}
Required Methods§
Sourcefn union(self) -> HyperLogLog<P, BITS>
fn union(self) -> HyperLogLog<P, BITS>
Returns a HyperLogLog that is the union of all HyperLogLogs in the iterator.
§Example
use hyperloglog_rs::prelude::*;
let mut hll1 = HyperLogLog::<Precision12, 6>::default();
hll1.insert(&1);
hll1.insert(&2);
let mut hll2 = HyperLogLog::<Precision12, 6>::default();
hll2.insert(&3);
hll2.insert(&4);
let mut hll3 = HyperLogLog::<Precision12, 6>::default();
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());