Package com.google.common.hash.HashCodes

Examples of com.google.common.hash.HashCodes.HashCodeSlicer


  /**
   * Returns {@code true} if the element <i>might</i> have been put in this Bloom filter,
   * {@code false} if this is <i>definitely</i> not the case.
   */
  public boolean mightContain(T instance) {
    HashCodeSlicer slicer = HashCodes.slice(
        hashFunction.newHasher().putObject(instance, funnel).hash(), hashBitsPerSlice);
    for (int i = 0; i < numHashFunctions; i++) {
      if (!bits.get(slicer.nextSlice())) {
        return false;
      }
    }
    return true;
  }
View Full Code Here


  /**
   * Puts an element into this {@code BloomFilter}. Ensures that subsequent invocations of
   * {@link #mightContain(Object)} with the same element will always return {@code true}.
   */
  public void put(T instance) {
    HashCodeSlicer slicer = HashCodes.slice(
        hashFunction.newHasher().putObject(instance, funnel).hash(), hashBitsPerSlice);
    for (int i = 0; i < numHashFunctions; i++) {
      int nextSlice = slicer.nextSlice();
      bits.set(nextSlice);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.common.hash.HashCodes.HashCodeSlicer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.