Package com.helger.commons.hashcode
Class HashCodeCalculator
- java.lang.Object
-
- com.helger.commons.hashcode.HashCodeCalculator
-
@Immutable public final class HashCodeCalculator extends Object
This class provides the hash code generation for different data types.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static intHASHCODE_NULLThe hash code value to be used fornullvalues.static intMULTIPLIEREach value is multiplied with this value. 31 because it can easily be optimized to(1 << 5) - 1.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intappend(int nPrevHashCode, boolean x)Atomic type hash code generation.static intappend(int nPrevHashCode, byte x)Atomic type hash code generation.static intappend(int nPrevHashCode, char x)Atomic type hash code generation.static intappend(int nPrevHashCode, double x)Atomic type hash code generation.static intappend(int nPrevHashCode, float x)Atomic type hash code generation.static intappend(int nPrevHashCode, int x)Atomic type hash code generation.static intappend(int nPrevHashCode, long x)Atomic type hash code generation.static intappend(int nPrevHashCode, short x)Atomic type hash code generation.static intappend(int nPrevHashCode, Object x)Object hash code generation.
-
-
-
Field Detail
-
MULTIPLIER
public static final int MULTIPLIER
Each value is multiplied with this value. 31 because it can easily be optimized to(1 << 5) - 1.- See Also:
- Constant Field Values
-
HASHCODE_NULL
public static final int HASHCODE_NULL
The hash code value to be used fornullvalues. Do not use 0 as e.g.BigDecimal ("0")also results in a 0 hash code.- See Also:
- Constant Field Values
-
-
Method Detail
-
append
public static int append(int nPrevHashCode, boolean x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
append
public static int append(int nPrevHashCode, byte x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
append
public static int append(int nPrevHashCode, char x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
append
public static int append(int nPrevHashCode, double x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
append
public static int append(int nPrevHashCode, float x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
append
public static int append(int nPrevHashCode, int x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
append
public static int append(int nPrevHashCode, long x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
append
public static int append(int nPrevHashCode, short x)Atomic type hash code generation.- Parameters:
nPrevHashCode- The previous hash code used as the basis for calculationx- Array to add- Returns:
- The updated hash code
-
-