in algebird-core/src/main/scala/com/twitter/algebird/BloomFilter.scala [382:407]
def maybeContains(item: A): Boolean
// Estimates the cardinality of the set of elements that have been
// inserted into the Bloom Filter.
def size: Approximate[Long]
def toBitSet: BitSet
/**
* Compute the Hamming distance between the two Bloom filters `a` and `b`. The distance is defined as the
* number of bits that need to change to in order to transform one filter into the other.
*/
def hammingDistance(that: BF[A]): Int =
(this, that) match {
// Comparing with empty filter should give number
// of bits in other set
case (_: BFZero[A], _: BFZero[A]) => 0
case (_: BFZero[A], y: BF[A]) => y.numBits
case (x: BF[A], _: BFZero[A]) => x.numBits
// Special case for Sparse vs. Sparse
case (x: BFSparse[A], y: BFSparse[A]) => x.bits.xorCardinality(y.bits)
// Otherwise compare as bit sets
case (_, _) => (this.toBitSet ^ that.toBitSet).size
}