Class CrossHash.Mist

java.lang.Object
com.github.yellowstonegames.old.v300.CrossHash.Mist
Enclosing class:
CrossHash

public static final class CrossHash.Mist extends Object
A whole cluster of Wisp-like hash functions that sacrifice a small degree of speed, but can be built with up to 128 bits of salt values that help to obscure what hashing function is actually being used. This class is similar to the older Storm variety, but is somewhat faster and has many more possible salt "states" when using the constructors that take two longs or a CharSequence. There isn't really any reason to use Storm, so Mist has now replaced Storm entirely. Code that used Storm should be able to just change any usage of "Storm" to "Mist", or can instead use CrossHash.Yolk or CrossHash.Curlup for higher quality and speed but smaller salt size.
The salt fields are not serialized, so it is important that the same salt will be given by the program when the same hash results are wanted for some inputs.
A group of 48 static, final, pre-initialized Mist members are present in this class, 24 with the name of a letter in the Greek alphabet (this uses the convention on Wikipedia where lambda is spelled with a 'b') and 24 with the same name followed by an underscore, such as alpha_. The whole group of 48 pre-initialized members are also present in a static array called predefined. These can be useful when, for example, you want to get multiple hashes of a single array or String as part of cuckoo hashing or similar techniques that need multiple hashes for the same inputs.
  • Field Details

  • Constructor Details

    • Mist

      public Mist()
    • Mist

      public Mist(CharSequence alteration)
    • Mist

      public Mist(long alteration)
    • Mist

      public Mist(long alteration1, long alteration2)
  • Method Details

    • randomize

      public CrossHash.Mist randomize()
      Makes a new Mist with all of the salt values altered based on the previous salt values. This will make a different, incompatible Mist object that will give different results than the original. Meant for use in Cuckoo Hashing, which can need the hash function to be updated or changed. An alternative is to select a different Mist object from predefined, or to simply construct a new Mist with a different parameter or set of parameters.
    • hash64

      public long hash64(boolean[] data)
    • hash64

      public long hash64(byte[] data)
    • hash64

      public long hash64(short[] data)
    • hash64

      public long hash64(char[] data)
    • hash64

      public long hash64(int[] data)
    • hash64

      public long hash64(long[] data)
    • hash64

      public long hash64(float[] data)
    • hash64

      public long hash64(double[] data)
    • hash64

      public long hash64(char[] data, int start, int end)
      Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).
      Parameters:
      data - the char array to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 64-bit hash code for the requested section of data
    • hash64

      public long hash64(char[] data, int start, int end, int step)
      Hashes only a subsection of the given data, starting at start (inclusive), ending before end (exclusive), and moving between chars in increments of step (which is always greater than 0).
      Parameters:
      data - the char array to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      step - how many elements to advance after using one element from data; must be greater than 0
      Returns:
      a 64-bit hash code for the requested section of data
    • hash64

      public long hash64(CharSequence data)
    • hash64

      public long hash64(char[][] data)
    • hash64

      public long hash64(long[][] data)
    • hash64

      public long hash64(CharSequence[] data)
    • hash64

      public long hash64(Iterable<? extends CharSequence> data)
    • hash64

      public long hash64(CharSequence[]... data)
    • hash64

      public long hash64(Object[] data)
    • hash64

      public long hash64(Object data)
    • hash

      public int hash(boolean[] data)
    • hash

      public int hash(byte[] data)
    • hash

      public int hash(short[] data)
    • hash

      public int hash(char[] data)
    • hash

      public int hash(int[] data)
    • hash

      public int hash(long[] data)
    • hash

      public int hash(float[] data)
    • hash

      public int hash(double[] data)
    • hash

      public int hash(char[] data, int start, int end)
      Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).
      Parameters:
      data - the char array to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 32-bit hash code for the requested section of data
    • hash

      public int hash(char[] data, int start, int end, int step)
      Hashes only a subsection of the given data, starting at start (inclusive), ending before end (exclusive), and moving between chars in increments of step (which is always greater than 0).
      Parameters:
      data - the char array to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      step - how many elements to advance after using one element from data; must be greater than 0
      Returns:
      a 32-bit hash code for the requested section of data
    • hash

      public int hash(CharSequence data)
    • hash

      public int hash(char[][] data)
    • hash

      public int hash(long[][] data)
    • hash

      public int hash(CharSequence[] data)
    • hash

      public int hash(Iterable<? extends CharSequence> data)
    • hash

      public int hash(CharSequence[]... data)
    • hash

      public int hash(Object[] data)
    • hash

      public int hash(Object data)