Package org.infinispan.commons.hash
Interface Hash
- All Known Implementing Classes:
CRC16
,MurmurHash3
public interface Hash
Interface that governs implementations
- Author:
- Manik Surtani, Patrick McFarland
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
hash
(byte[] payload) Hashes a byte array efficiently.int
hash
(int hashcode) An incremental version of the hash function, that spreads a pre-calculated hash code, such as one derived fromObject.hashCode()
.int
A helper that calculates the hashcode of an object, choosing the optimal mechanism of hash calculation after considering the type of the object (byte array, String or Object).default int
How many bits this hash function may utilize.
-
Method Details
-
hash
int hash(byte[] payload) Hashes a byte array efficiently.- Parameters:
payload
- a byte array to hash- Returns:
- a hash code for the byte array
-
hash
int hash(int hashcode) An incremental version of the hash function, that spreads a pre-calculated hash code, such as one derived fromObject.hashCode()
.- Parameters:
hashcode
- an object's hashcode- Returns:
- a spread and hashed version of the hashcode
-
hash
A helper that calculates the hashcode of an object, choosing the optimal mechanism of hash calculation after considering the type of the object (byte array, String or Object).- Parameters:
o
- object to hash- Returns:
- a hashcode
-
maxHashBits
default int maxHashBits()How many bits this hash function may utilize. By default a hash algorithm is assumed to use all 32 bits producing a value in the full range of int values.- Returns:
- how many bits the resulting int may use
-