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: 2017/02/22 18:30 (external edit)

Access website using Tor Access website using i2p


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