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

inthashpair(Object o1, Object o2)
hashpair
return combine(combine(0, o1), o2);
byte[]hashPoint(int hashlength, double fraction)
returns fraction*FFFF...FF (hashlenth bytes), represented in hex 0th byte is most significant
int ones = 0xff;
byte[] rslt = new byte[hashlength];
double remainder = 0;
for (int i = 0; i < rslt.length; i++) {
    double product = (fraction * ones) + (remainder * 256);
    int intpart = (int) product;
    remainder = (product - intpart);
    rslt[i] = (byte) intpart;
...
inthashSetSize(final int nrOfElements)
Return a good value for creation of a hash set (to not resize) given a number of elements you wish to insert.
assert nrOfElements >= 0;
return (int) Math.ceil(((double) nrOfElements) / LOAD_FACTOR);
inthashThem(Object one, Object two)

Return a composite hash code of two objects.

return hashIt(one) | hashIt(two);
floathashToFloat(int x, int y, long seed)
Hashes a 2D location and seed to return a normalized float.
final long hash = x * 73428767 ^ y * 9122569 ^ seed * 457;
return (hash * (hash + 456149) & 0x00ffffff) / (float) 0x01000000;
longhashToLong(final byte[] hash)
hash To Long
long ret = 0;
for (int i = 5; i >= 0; i--)
    ret += (hash[i] & 0xFF) * Math.pow(256, 5 - i);
return ret;
StringhashToName(long l)
Converts a long hash to a string.
int i = 0;
char ac[] = new char[12];
while (l != 0L) {
    long l1 = l;
    l /= 37L;
    ac[11 - i++] = VALID_CHARS[(int) (l1 - l * 37L)];
return new String(ac, 12 - i, i);
...
inthashV(Object... a)
Computes a hash code over var args.
int h = 19690721;
for (Object o : a) {
    h = hash(h, o);
return h;
inthashValueFor(final boolean b)
hash Value For
return b ? 1 : 0;
StringtoHash(Long number)
Returns a String representation of the number provided as an unsigned integer in base 16.
return (number == null) ? null : Long.toHexString(number);