Java Utililty Methods Hash Calculate

List of utility methods to do Hash Calculate

Description

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

Method

inthashCapacityForSize(final int size)
Returns the minimal capacity of hash-based structures (e.g.
return size * 4 / 3 + 1;
inthashCharArray(int seed, char... charArray)
Calculates hash code for char array.
return hash(seed, charArray);
inthashClassName(Class clazz)
hash Class Name
String className = clazz.getName();
return hashString(className);
inthashCombine(int seed, int hash)
from clojure.Util
return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2));
inthashCombine(int seed, int hash)
hash Combine
seed ^= hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed;
voidhashDisp(long hash)
hash Disp
long cntrl = hash & 0xFF;
long cmd = (hash >> 8) & 0xFF;
long chn = (hash >> 16) & 0xFF;
System.out.println(chn + "  " + cmd + " " + cntrl);
inthashDouble(double val)
hash Double
long bits = Double.doubleToLongBits(val);
return (int) (bits ^ bits >>> 32);
booleanhashEqules(Object source, Object obj)
hash Equles
return (hash(source) == hash(obj));
inthashFloat(float value)
hash Float
return Float.floatToIntBits(value);
longhashFloatBits(long hash, float f)
hash Float Bits
hash *= 31L;
if (f == 0.0f)
    return hash;
return hash + Float.floatToIntBits(f);