Class CrossHash.Mist
java.lang.Object
com.github.yellowstonegames.old.v300.CrossHash.Mist
- Enclosing class:
CrossHash
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
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
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Mistlonglongstatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Mist[]Has a length of 48, which may be relevant if automatically choosing a predefined hash functor.static final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Miststatic final CrossHash.Mist -
Constructor Summary
ConstructorsConstructorDescriptionMist()Mist(long alteration) Mist(long alteration1, long alteration2) Mist(CharSequence alteration) -
Method Summary
Modifier and TypeMethodDescriptioninthash(boolean[] data) inthash(byte[] data) inthash(char[] data) inthash(char[][] data) inthash(char[] data, int start, int end) Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).inthash(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).inthash(double[] data) inthash(float[] data) inthash(int[] data) inthash(long[] data) inthash(long[][] data) inthash(short[] data) inthash(CharSequence data) inthash(CharSequence[] data) inthash(CharSequence[]... data) inthash(Iterable<? extends CharSequence> data) intintlonghash64(boolean[] data) longhash64(byte[] data) longhash64(char[] data) longhash64(char[][] data) longhash64(char[] data, int start, int end) Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).longhash64(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).longhash64(double[] data) longhash64(float[] data) longhash64(int[] data) longhash64(long[] data) longhash64(long[][] data) longhash64(short[] data) longhash64(CharSequence data) longhash64(CharSequence[] data) longhash64(CharSequence[]... data) longhash64(Iterable<? extends CharSequence> data) longlongMakes a new Mist with all of the salt values altered based on the previous salt values.
-
Field Details
-
l1
public long l1 -
l2
public long l2 -
alpha
-
beta
-
gamma
-
delta
-
epsilon
-
zeta
-
eta
-
theta
-
iota
-
kappa
-
lambda
-
mu
-
nu
-
xi
-
omicron
-
pi
-
rho
-
sigma
-
tau
-
upsilon
-
phi
-
chi
-
psi
-
omega
-
alpha_
-
beta_
-
gamma_
-
delta_
-
epsilon_
-
zeta_
-
eta_
-
theta_
-
iota_
-
kappa_
-
lambda_
-
mu_
-
nu_
-
xi_
-
omicron_
-
pi_
-
rho_
-
sigma_
-
tau_
-
upsilon_
-
phi_
-
chi_
-
psi_
-
omega_
-
predefined
Has a length of 48, which may be relevant if automatically choosing a predefined hash functor.
-
-
Constructor Details
-
Mist
public Mist() -
Mist
-
Mist
public Mist(long alteration) -
Mist
public Mist(long alteration1, long alteration2)
-
-
Method Details
-
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 frompredefined, 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 hashstart- 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 hashstart- 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
-
hash64
public long hash64(char[][] data) -
hash64
public long hash64(long[][] data) -
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
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 hashstart- 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 hashstart- 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
-
hash
public int hash(char[][] data) -
hash
public int hash(long[][] data) -
hash
-
hash
-
hash
-
hash
-
hash
-