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

inthashJenkins(int init, Object... vals)
hash Jenkins
if (vals == null || vals.length == 0) {
    return init;
int a, b, c;
a = b = c = BASE + (vals.length << 2) + init;
int pos = 0;
while (vals.length - pos > 3) {
    a += vals[pos].hashCode();
...
inthashLong(long id)
hash Long
return (int) (id ^ id >>> 32);
inthashLong(long l)
Returns a hash code for a long.
return (int) (l ^ (l >>> 32));
inthashMapCapacity(final int nElements)
return a good initialCapacity for a HashMap that will hold a given number of elements
return (int) ((nElements * 4L) / 3) + 1;
inthashMore(final int hash, final int more)
hash More
int result = hash << 1;
if (result < 0)
    result |= 1;
return result ^ more;
longhashName(CharSequence name)
hash Name
long hash = 0L;
int size = name.length();
for (int index = 0; index < size; index++) {
    hash *= 37L;
    char c = name.charAt(index);
    if (c >= 'A' && c <= 'Z') {
        hash += (long) ('\001' + c - 'A');
    } else if (c >= 'a' && c <= 'z') {
...
inthashObject(Object obj)
A convenience function for hashing an object without getting NullPointerException s
return obj == null ? 0 : obj.hashCode();
inthashOrNull(Object value)
hash Or Null
return value == null ? 1 : value.hashCode();
inthashOrZero(Object o)
Note -- if you are using Arrays.equals( ...
return (o == null ? 0 : o.hashCode());
longhashPair(int a, int b)
Generates a unique number based from two arguments.
if (a >= 0 || b >= 0) {
    return a >= b ? a * a + a + b : a + b * b;
} else {
    throw new IllegalArgumentException("a and b must be positive.");