VarCountingBloomFilter implements IFilter<String> { public void merge(VarCountingBloomFilter cbf) { assert cbf != null; assert buckets.length == cbf.buckets.length; assert hashCount == cbf.hashCount; for ( int i = 0; i < buckets(); ++i ) { Bucket b = new Bucket(i); Bucket b2 = cbf.getBucket(i); long merged = b.value + b2.value; b.set(merged > maxCount ? maxCount : merged); } } VarCountingBloomFilter(int numElements, int bucketsPerElement, int exp); void clear(); void merge(VarCountingBloomFilter cbf); boolean membershipTest(String item); void add(String item); void delete(String item); double getPercentNonZero();  }
@Test public void testMerge() { cbf.clear(); cbf.add("a"); cbf.add("a"); VarCountingBloomFilter cbf2 = new VarCountingBloomFilter(ELEMENTS, spec.bucketsPerElement, EXP); cbf2.add("a"); cbf2.add("a"); cbf.merge(cbf2); assertEquals(4, cbf.maxBucket()); }