Package squidpony.squidmath
Class CrossHash.Mist
java.lang.Object
squidpony.squidmath.CrossHash.Mist
- All Implemented Interfaces:
Serializable
- Enclosing class:
- CrossHash
public static final class CrossHash.Mist extends Object implements Serializable
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, https://en.wikipedia.org/wiki/Greek_alphabet#Letters , 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, https://en.wikipedia.org/wiki/Greek_alphabet#Letters , 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.- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Mist()
Mist(long alteration)
Mist(long alteration1, long alteration2)
Mist(CharSequence alteration)
-
Method Summary
Modifier and Type Method Description int
hash(boolean[] data)
int
hash(byte[] data)
int
hash(char[] data)
int
hash(char[][] data)
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).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).int
hash(double[] data)
int
hash(float[] data)
int
hash(int[] data)
int
hash(long[] data)
int
hash(long[][] data)
int
hash(short[] data)
int
hash(CharSequence data)
int
hash(CharSequence[] data)
int
hash(CharSequence[]... data)
int
hash(Iterable<? extends CharSequence> data)
int
hash(Object data)
int
hash(Object[] data)
long
hash64(boolean[] data)
long
hash64(byte[] data)
long
hash64(char[] data)
long
hash64(char[][] data)
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).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).long
hash64(double[] data)
long
hash64(float[] data)
long
hash64(int[] data)
long
hash64(long[] data)
long
hash64(long[][] data)
long
hash64(short[] data)
long
hash64(CharSequence data)
long
hash64(CharSequence[] data)
long
hash64(CharSequence[]... data)
long
hash64(Iterable<? extends CharSequence> data)
long
hash64(Object data)
long
hash64(Object[] data)
CrossHash.Mist
randomize()
Makes a new Mist with all of the salt values altered based on the previous salt values.
-
Field Details
-
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
-
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
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
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
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
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
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
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
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-