Package org.codehaus.groovy.util
Class HashCodeHelper
java.lang.Object
org.codehaus.groovy.util.HashCodeHelper
A utility class to help calculate hashcode values
using an algorithm similar to that outlined in
"Effective Java, Joshua Bloch, 2nd Edition".
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intinitHash()Returns the initial seed for a hash-code calculation sequence.static intupdateHash(int current, boolean var) Mixes a boolean value into an in-progress hash code.static intupdateHash(int current, boolean[] var) Mixes a boolean-array value into an in-progress hash code.static intupdateHash(int current, byte[] var) Mixes a byte-array value into an in-progress hash code.static intupdateHash(int current, char var) Mixes a character value into an in-progress hash code.static intupdateHash(int current, char[] var) Mixes a char-array value into an in-progress hash code.static intupdateHash(int current, double var) Mixes a double value into an in-progress hash code.static intupdateHash(int current, double[] var) Mixes a double-array value into an in-progress hash code.static intupdateHash(int current, float var) Mixes a float value into an in-progress hash code.static intupdateHash(int current, float[] var) Mixes a float-array value into an in-progress hash code.static intupdateHash(int current, int var) Mixes an integer value into an in-progress hash code.static intupdateHash(int current, int[] var) Mixes an int-array value into an in-progress hash code.static intupdateHash(int current, long var) Mixes a long value into an in-progress hash code.static intupdateHash(int current, long[] var) Mixes a long-array value into an in-progress hash code.static intupdateHash(int current, short[] var) Mixes a short-array value into an in-progress hash code.static intupdateHash(int current, Character var) Mixes a boxed character value into an in-progress hash code.static intupdateHash(int current, Double var) Mixes a boxed double value into an in-progress hash code.static intupdateHash(int current, Float var) Mixes a boxed float value into an in-progress hash code.static intupdateHash(int current, Integer var) Mixes a boxed integer value into an in-progress hash code.static intupdateHash(int current, Long var) Mixes a boxed long value into an in-progress hash code.static intupdateHash(int current, Object var) Mixes an object or object-array value into an in-progress hash code.
-
Constructor Details
-
HashCodeHelper
public HashCodeHelper()
-
-
Method Details
-
initHash
public static int initHash()Returns the initial seed for a hash-code calculation sequence.- Returns:
- the starting hash value
-
updateHash
public static int updateHash(int current, boolean var) Mixes a boolean value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, char var) Mixes a character value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
Mixes a boxed character value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, int var) Mixes an integer value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
Mixes a boxed integer value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, long var) Mixes a long value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
Mixes a boxed long value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, float var) Mixes a float value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
Mixes a boxed float value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, double var) Mixes a double value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
Mixes a boxed double value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
Mixes an object or object-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, boolean[] var) Mixes a boolean-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, char[] var) Mixes a char-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, byte[] var) Mixes a byte-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, short[] var) Mixes a short-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, int[] var) Mixes an int-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, long[] var) Mixes a long-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, float[] var) Mixes a float-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-
updateHash
public static int updateHash(int current, double[] var) Mixes a double-array value into an in-progress hash code.- Parameters:
current- the current hash valuevar- the value to mix in- Returns:
- the updated hash value
-