Created
July 14, 2013 06:59
-
-
Save lichenbo/5993454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int hash(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); | |
} | |
static int indexFor(int h, int length) { | |
return h & (length-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment