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

inthash64to32(long v)
hashto
v = v = (v << 18) - v - 1; 
v = v ^ (v >>> 31);
v = (v + (v << 2)) + (v << 4); 
v = v ^ (v >>> 11);
v = v + (v << 6);
v = v ^ (v >>> 22);
return (int) v;
inthashAdd(final int left, final int right)
hash Add
return 37 * (left + right);
inthashAll(Object[] array)
finds a hash value which takes into account the value of all elements, such that two object arrays for which Arrays.equals(a1, a2) returns true will hashAll() to the same value
int out = 0;
for (int i = 0, len = array.length; i < len; ++i) {
    Object o = array[i];
    if (o != null)
        out ^= o.hashCode();
return out;
booleanhasHangulJongSung(char ch)
has Hangul Jong Sung
return isHangulSyllables(ch) && (ch - 0xAC00) % 28 > 0;
inthashArray(int h, Object[] a)
Computes a hash code from an existing hash code and an array of objects (which may be null).
if (a == null) {
    return hash(h, 19690429);
if (a.length == 0) {
    return hash(h, 19690721);
for (Object anA : a) {
    h = hash(h, anA);
...
inthashArray(Object[] array)
Utility to hash an array.
if (null == array) {
    return 0;
int hash = 0;
for (Object object : array) {
    hash ^= hashValue(object);
return hash;
...
inthashArray(Object[] objs)
hash Array
int ret = 1;
for (int i = 0; i < objs.length; i++) {
    ret = 31 * ret + (objs[i] == null ? 0 : objs[i].hashCode());
return ret;
longhashBerkeleyDB64(byte[] str)
A hash function used in Berkeley DB
long hash = 0;
for (int i = 0; i < str.length; i++) {
    hash = str[i] + (hash << 6) + (hash << 16) - hash;
return hash;
bytehashByteArray(byte[] array, int startInclusive, int endExclusive)
A utility to allow hashing of a portion of an array without having to copy it.
if (array == null) {
    return 0;
int range = endExclusive - startInclusive;
if (range < 0) {
    throw new IllegalArgumentException(startInclusive + " > " + endExclusive);
int result = 1;
...
inthashBytes(int seed, byte[] data, int offset, int len)
hash Bytes
int h1 = seed;
int count = len;
while (count >= 4) {
    int k1 = (data[offset] & 0x0FF) | (data[offset + 1] & 0x0FF) << 8 | (data[offset + 2] & 0x0FF) << 16
            | data[offset + 3] << 24;
    count -= 4;
    offset += 4;
    k1 *= 0xcc9e2d51;
...