Class HashMixer

java.lang.Object
com.pervasive.datarush.util.HashMixer

public final class HashMixer extends Object
A representation of a partially completed hash of a sequence of values. The internal state contains more bits than the final 32-bit hash code.

This implementation is based on C code placed in the public domain by Bob Jenkins. It is advertised as strong enough to allow the use of hash & mask instead of hash % prime for computing a hash bucket.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a mixer by initializing the internal state.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    finalMix(int i, int j, int k)
    Performs the final "mix" of the internal state with the given parameters, resets the state, and returns the resulting hash code.
    void
    mix(int i, int j, int k)
    Replicates the computation of Bob Jenkins' "mix" macro.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HashMixer

      public HashMixer()
      Constructs a mixer by initializing the internal state.
  • Method Details

    • mix

      public void mix(int i, int j, int k)
      Replicates the computation of Bob Jenkins' "mix" macro.
      Parameters:
      i - the first input to the macro
      j - the second input to the macro
      k - the third input to the macro
    • finalMix

      public int finalMix(int i, int j, int k)
      Performs the final "mix" of the internal state with the given parameters, resets the state, and returns the resulting hash code.
      Parameters:
      i - the first four bytes to include
      j - the second four bytes to include
      k - the final four bytes to include
      Returns:
      the hash code produced by "mixing" initial state, parameters to each call of mix(int, int, int), and parameters to finalMix(int, int, int)