public interface Hasher32
A 32-bit hash function.
Instances are immutable. Therefore, it is safe to use a single instance across multiple threads and for multiple hash calculations.
-
Method Summary
Modifier and TypeMethodDescriptionintThe size of the hash value in bits.inthashBytesToInt(byte[] input) Hashes a byte array to a 32-bit integer value.inthashBytesToInt(byte[] input, int off, int len) Hashes a byte array to a 32-bit integer value.inthashCharsToInt(CharSequence input) Hashes aCharSequenceto a 32-bitintvalue.inthashIntIntIntToInt(int v1, int v2, int v3) Hashes/Mixes three 32-bitintvalues into a 32-bitintvalue.inthashIntLongToInt(int v1, long v2) Hashes/Mixes a 32-bitintvalue and a 64-bitlongvalue into a 32-bitintvalue.inthashLongIntToInt(long v1, int v2) Hashes/Mixes a 64-bitlongvalue and a 32-bitintvalue into a 32-bitintvalue.inthashLongLongLongToInt(long v1, long v2, long v3) Hashes/Mixes three 64-bitlongvalues into a 32-bitintvalue.inthashLongLongToInt(long v1, long v2) Hashes/Mixes two 64-bitlongvalues into a 32-bitintvalue.<T> inthashToInt(T obj, HashFunnel<T> funnel) Hashes an object to a 32-bit integer value.
-
Method Details
-
hashStream
HashStream32 hashStream() -
hashToInt
Hashes an object to a 32-bit integer value.- Type Parameters:
T- the type- Parameters:
obj- the objectfunnel- the funnel- Returns:
- the hash value
-
hashBytesToInt
int hashBytesToInt(byte[] input) Hashes a byte array to a 32-bit integer value.Equivalent to
hashBytesToInt(input, 0, input.length).- Parameters:
input- the byte array- Returns:
- the hash value
-
hashBytesToInt
int hashBytesToInt(byte[] input, int off, int len) Hashes a byte array to a 32-bit integer value.Equivalent to
hashToInt(input, (b, f) -> f.putBytes(b, off, len)).- Parameters:
input- the byte arrayoff- the offsetlen- the length- Returns:
- the hash value
-
hashCharsToInt
Hashes aCharSequenceto a 32-bitintvalue.Equivalent to
hashToInt(input, (c, f) -> f.putChars(c)).- Parameters:
input- the char sequence- Returns:
- the hash value
-
hashLongLongToInt
int hashLongLongToInt(long v1, long v2) Hashes/Mixes two 64-bitlongvalues into a 32-bitintvalue.Equivalent to
hashStream().putLong(v1).putLong(v2).getAsInt();- Parameters:
v1- first valuev2- second value- Returns:
- the hash value
-
hashLongLongLongToInt
int hashLongLongLongToInt(long v1, long v2, long v3) Hashes/Mixes three 64-bitlongvalues into a 32-bitintvalue.Equivalent to
hashStream().putLong(v1).putLong(v2).putLong(v3).getAsInt();- Parameters:
v1- first valuev2- second valuev3- third value- Returns:
- the hash value
-
hashLongIntToInt
int hashLongIntToInt(long v1, int v2) Hashes/Mixes a 64-bitlongvalue and a 32-bitintvalue into a 32-bitintvalue.Equivalent to
hashStream().putLong(v1).putInt(v2).getAsInt();- Parameters:
v1- first valuev2- second value- Returns:
- the hash value
-
hashIntLongToInt
int hashIntLongToInt(int v1, long v2) Hashes/Mixes a 32-bitintvalue and a 64-bitlongvalue into a 32-bitintvalue.Equivalent to
hashStream().putInt(v1).putLong(v2).getAsInt();- Parameters:
v1- first valuev2- second value- Returns:
- the hash value
-
hashIntIntIntToInt
int hashIntIntIntToInt(int v1, int v2, int v3) Hashes/Mixes three 32-bitintvalues into a 32-bitintvalue.Equivalent to
hashStream().putInt(v1).putInt(v2).putInt(v3).getAsInt();- Parameters:
v1- first valuev2- second valuev3- third value- Returns:
- the hash value
-
getHashBitSize
int getHashBitSize()The size of the hash value in bits.- Returns:
- the size of the hash value in bits
-