Table of Contents

About

The following is a collection of hash functions for integers.

Thomas Wang

Does not work too well with integers that are multiples of $34$.

unsigned int TWHash(unsigned int a) {
    a = (a ^ 61) ^ (a >> 16);
    a = a + (a << 3);
    a = a ^ (a >> 4);
    a = a * 0x27d4eb2d;
    a = a ^ (a >> 15);
    return a;
}

Java HashMap

private static int JavaHash(int h) {
    // This function ensures that hashCodes that differ only by
    // constant multiples at each bit position have a bounded
    // number of collisions (approximately 8 at default load factor).
    h ^= (h >> > 20) ^ (h >> > 12);
    return h ^ (h >> > 7) ^ (h >> > 4);
}

fuss/hash_functions/integers.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.