@Test public void testExpectedFalsePositiveProbability() { assertEquals(0.0, filter.expectedFalsePositiveProbability(), 0.001); filter.add("one"); assertEquals(0.04, filter.expectedFalsePositiveProbability(), 0.001); filter.add("two"); assertEquals(0.09, filter.expectedFalsePositiveProbability(), 0.001); filter.add("three"); assertEquals(0.09, filter.expectedFalsePositiveProbability(), 0.001); filter.add("four"); assertEquals(0.16, filter.expectedFalsePositiveProbability(), 0.001); filter.add("five"); assertEquals(0.25, filter.expectedFalsePositiveProbability(), 0.001); }
@Override public void add(final T element) { for (final Function<T, Integer> hashFunction : hashFunctions) { final int hashValue = hashFunction.apply(element); final int hashBasedIndex = getSafeIndexFromHash(hashValue); bits.set(hashBasedIndex); } }
DefaultBloomFilter implements BloomFilter<T> { @Override public void add(final T element) { for (final Function<T, Integer> hashFunction : hashFunctions) { final int hashValue = hashFunction.apply(element); final int hashBasedIndex = getSafeIndexFromHash(hashValue); bits.set(hashBasedIndex); } } }
DefaultBloomFilter implements BloomFilter<T> { @Override public void add(final T element) { for (final Function<T, Integer> hashFunction : hashFunctions) { final int hashValue = hashFunction.apply(element); final int hashBasedIndex = getSafeIndexFromHash(hashValue); bits.set(hashBasedIndex); } } @SafeVarargs  DefaultBloomFilter(final int numBits, final Function<T, Integer>... hashFunctions); }
DefaultBloomFilter implements BloomFilter<T> { @Override public void add(final T element) { for (final Function<T, Integer> hashFunction : hashFunctions) { final int hashValue = hashFunction.apply(element); final int hashBasedIndex = getSafeIndexFromHash(hashValue); bits.set(hashBasedIndex); } } @SafeVarargs  DefaultBloomFilter(final int numBits, final Function<T, Integer>... hashFunctions); @Override boolean probablyContains(final T element); @Override void add(final T element); @Override int getNumberOfActiveBits(); @Override int getNumberOfBits(); @Override int getNumberOfHashFunctions(); @Override String toString(); }
DefaultBloomFilter implements BloomFilter<T> { @Override public void add(final T element) { for (final Function<T, Integer> hashFunction : hashFunctions) { final int hashValue = hashFunction.apply(element); final int hashBasedIndex = getSafeIndexFromHash(hashValue); bits.set(hashBasedIndex); } } @SafeVarargs  DefaultBloomFilter(final int numBits, final Function<T, Integer>... hashFunctions); @Override boolean probablyContains(final T element); @Override void add(final T element); @Override int getNumberOfActiveBits(); @Override int getNumberOfBits(); @Override int getNumberOfHashFunctions(); @Override String toString();  }