public final class HashCode extends Object
Modifier and Type | Class and Description |
---|---|
static class |
HashCode.GetHashCodeFunction<T>
A delegate that obtains a hash code for a given item.
|
Modifier and Type | Method and Description |
---|---|
static int |
combine(int... hashes)
Combines an arbitrary number of hash codes.
|
static int |
combine(int hash1,
int hash2)
Combines two hash codes.
|
static int |
combine(int hash1,
int hash2,
int hash3)
Combines three hash codes.
|
static int |
combine(int hash1,
int hash2,
int hash3,
int hash4)
Combines four hash codes.
|
static int |
combine(int hash1,
int hash2,
int hash3,
int hash4,
int hash5)
Combines five hash codes.
|
static int |
getHashCode(boolean b)
Gets a hash code for a specified boolean.
|
static int |
getHashCode(double d)
Gets a hash code for a specified double.
|
static int |
getHashCode(double[] array)
Gets a hash code for the items in the specified array.
|
static int |
getHashCode(double[][] array)
Gets a hash code for the items in the specified two dimensional array.
|
static int |
getHashCode(int i)
Gets a hash code for a specified int.
|
static <T> int |
getHashCode(Iterable<T> items)
Gets a hash code for the items in the specified sequence.
|
static <T> int |
getHashCode(Iterable<T> items,
HashCode.GetHashCodeFunction<T> hashCodeFunction)
Gets a hash code for the items in the specified sequence.
|
static int |
getHashCode(Object o)
Gets a hash code for a specified object, or zero if the object is
null . |
static int |
getHashCode(String s)
Gets a hash code for a specified string, or zero if the string is
null . |
static <T> int |
getHashCode(T[] array)
Gets a hash code for the items in the specified array.
|
static <T> int |
getHashCode(T[][] array)
Gets a hash code for the items in the specified two dimensional array.
|
static <T> int |
getHashCode(T[][] array,
HashCode.GetHashCodeFunction<T> hashCodeFunction)
Gets a hash code for the items in the specified two dimensional array.
|
static <T> int |
getHashCode(T[] array,
HashCode.GetHashCodeFunction<T> hashCodeFunction)
Gets a hash code for the items in the specified array.
|
public static int combine(int hash1, int hash2)
This method is based on the MurmurHash3 algorithm.
hash1
- The first hash code.hash2
- The second hash code.public static int combine(int hash1, int hash2, int hash3)
This method is based on the MurmurHash3 algorithm.
hash1
- The first hash code.hash2
- The second hash code.hash3
- The third hash code.public static int combine(int hash1, int hash2, int hash3, int hash4)
This method is based on the MurmurHash3 algorithm.
hash1
- The first hash code.hash2
- The second hash code.hash3
- The third hash code.hash4
- The fourth hash code.public static int combine(int hash1, int hash2, int hash3, int hash4, int hash5)
This method is based on the MurmurHash3 algorithm.
hash1
- The first hash code.hash2
- The second hash code.hash3
- The third hash code.hash4
- The fourth hash code.hash5
- The fifth hash code.public static int combine(@Nonnull int... hashes)
This method is based on the MurmurHash3 algorithm.
hashes
- The hash codes.public static int getHashCode(@Nullable Object o)
null
.o
- The object for which to get the hash code.null
.public static int getHashCode(@Nullable String s)
null
.s
- The string for which to get the hash code.null
.public static int getHashCode(double d)
Double.hashCode()
and is provided for convenience.d
- The double for which to get the hash code.public static int getHashCode(int i)
Integer.hashCode()
and is provided for convenience.i
- The int for which to get the hash code.public static int getHashCode(boolean b)
Boolean.hashCode()
and is provided for convenience.b
- The boolean for which to get the hash code.public static <T> int getHashCode(@Nullable Iterable<T> items)
HashCode.combine(int[])
to combine the hash codes of the items in the sequence. If
items
is null, the returned hash code is zero.T
- The type of item in the sequence.items
- The sequence of items for which to get the hash code.public static <T> int getHashCode(@Nullable Iterable<T> items, @Nonnull HashCode.GetHashCodeFunction<T> hashCodeFunction)
HashCode.combine(int[])
to combine the hash codes of the items in the sequence. If
items
is null, the returned hash code is zero.T
- The type of item in the sequence.items
- The sequence of items for which to get the hash code.hashCodeFunction
- A function for computing the hash code for a given item in the collection.public static <T> int getHashCode(@Nullable T[] array)
HashCode.combine(int[])
to combine the hash codes of the items in the array. If the array is null, the
returned hash code is zero.T
- The type of item in the array.array
- The array for which to get the hash code.public static int getHashCode(@Nullable double[] array)
HashCode.combine(int[])
to combine the hash codes of the items in the array. If the array is null, the
returned hash code is zero.array
- The array for which to get the hash code.public static <T> int getHashCode(@Nullable T[] array, @Nonnull HashCode.GetHashCodeFunction<T> hashCodeFunction)
HashCode.combine(int[])
to combine the hash codes of the items in the array. If the array is null, the
returned hash code is zero.T
- The type of item in the array.array
- The array for which to get the hash code.hashCodeFunction
- A function for computing the hash code for a given item in the collection.public static <T> int getHashCode(@Nullable T[][] array)
HashCode.combine(int[])
to combine the hash codes of the items in the array. If the array is null, the
returned hash code is zero.T
- The type of item in the array.array
- The two dimensional array for which to get the hash code.public static int getHashCode(@Nullable double[][] array)
HashCode.combine(int[])
to combine the hash codes of the items in the array. If the array is null, the
returned hash code is zero.array
- The two dimensional array for which to get the hash code.public static <T> int getHashCode(@Nullable T[][] array, @Nonnull HashCode.GetHashCodeFunction<T> hashCodeFunction)
HashCode.combine(int[])
to combine the hash codes of the items in the array. If the array is null, the
returned hash code is zero.T
- The type of item in the array.array
- The two dimensional array for which to get the hash code.hashCodeFunction
- A function for computing the hash code for a given item in the collection.