Java Utililty Methods Hash Code Calculate

List of utility methods to do Hash Code Calculate

Description

The list of methods to do Hash Code Calculate are organized into topic(s).

Method

inthashCode(int[] ai)
hash Code
int hashcode = 0;
for (int i : ai) {
    hashcode = hashcode * 31 + i;
return hashcode;
inthashCode(int[] array)
Returns a hash code value for the array
final int prime = 31;
if (array == null)
    return 0;
int result = 1;
for (int index = 0; index < array.length; index++) {
    result = (prime * result) + array[index];
return result;
...
inthashCode(int[][] arrays)
hash Code
if (arrays == null) {
    return 0;
int result = 1;
int h = arrays.length;
int w = arrays[0].length;
int value = 0;
for (int i = 0; i < h; i++) {
...
inthashCode(Iterable iterable)
Generates a Object#hashCode() for a given Iterable and its elements.
final int prime = 31;
int result = 1;
if (iterable != null) {
    for (Object object : iterable) {
        result = prime * result + ((object == null) ? 0 : object.hashCode());
return result;
...
inthashCode(long a[])
Returns a hash code based on the contents of the specified array.
if (a == null)
    return 0;
int result = 1;
for (long element : a) {
    int elementHash = (int) (element ^ (element >>> 32));
    result = 31 * result + elementHash;
return result;
...
inthashCode(long longVal)
Get standard Java hashCode for a long without the extra object creation.
return (int) (longVal ^ (longVal >>> 32));
inthashCode(long value)
Return a hash code of the given long integer value.
return (int) (value ^ (value >>> Integer.SIZE));
inthashCode(long x)
Compute a hash code for the given bitset.
long hash = 0x76543210L ^ x;
return (int) ((hash >> 32) ^ hash);
inthashCode(long[] a, int fromIndex, int toIndex)
hash Code
int hashCode = 1;
int i = fromIndex;
while (i < toIndex) {
    long v = a[i];
    hashCode = 31 * hashCode + (int) (v ^ (v >>> 32));
    ++i;
return hashCode;
...
inthashCode(Object a)
Get the hashCode of an object.
try {
    return a.hashCode();
} catch (NullPointerException ex) {
    if (a == null) {
        return 0;
    } else {
        throw ex;