Skip to content

Instantly share code, notes, and snippets.

@strangeglyph
Created October 10, 2016 00:16
Show Gist options
  • Save strangeglyph/412368f2e3630187d75a2c78b1788410 to your computer and use it in GitHub Desktop.
Save strangeglyph/412368f2e3630187d75a2c78b1788410 to your computer and use it in GitHub Desktop.
int[] lookupTable = new int[] {
0b00000000_00000000_00000000_00000000,
0b00000000_00000000_00000000_00000001,
0b00000000_00000000_00000000_00001000,
0b00000000_00000000_00000000_00001001,
0b00000000_00000000_00000000_01000000,
0b00000000_00000000_00000000_01000001,
0b00000000_00000000_00000000_01001000,
0b00000000_00000000_00000000_01001001,
0b00000000_00000000_00000010_00000000,
0b00000000_00000000_00000010_00000001,
0b00000000_00000000_00000010_00001000,
0b00000000_00000000_00000010_00001001,
0b00000000_00000000_00000010_01000000,
0b00000000_00000000_00000010_01000001,
0b00000000_00000000_00000010_01001000,
0b00000000_00000000_00000010_01001001,
0b00000000_00000000_00010000_00000000,
0b00000000_00000000_00010000_00000001,
0b00000000_00000000_00010000_00001000,
0b00000000_00000000_00010000_00001001,
0b00000000_00000000_00010000_01000000,
0b00000000_00000000_00010000_01000001,
0b00000000_00000000_00010000_01001000,
0b00000000_00000000_00010000_01001001,
0b00000000_00000000_00010010_00000000,
0b00000000_00000000_00010010_00000001,
0b00000000_00000000_00010010_00001000,
0b00000000_00000000_00010010_00001001,
0b00000000_00000000_00010010_01000000,
0b00000000_00000000_00010010_01000001,
0b00000000_00000000_00010010_01001000,
0b00000000_00000000_00010010_01001001,
0b00000000_00000000_10000000_00000000,
0b00000000_00000000_10000000_00000001,
0b00000000_00000000_10000000_00001000,
0b00000000_00000000_10000000_00001001,
0b00000000_00000000_10000000_01000000,
0b00000000_00000000_10000000_01000001,
0b00000000_00000000_10000000_01001000,
0b00000000_00000000_10000000_01001001,
0b00000000_00000000_10000010_00000000,
0b00000000_00000000_10000010_00000001,
0b00000000_00000000_10000010_00001000,
0b00000000_00000000_10000010_00001001,
0b00000000_00000000_10000010_01000000,
0b00000000_00000000_10000010_01000001,
0b00000000_00000000_10000010_01001000,
0b00000000_00000000_10000010_01001001,
0b00000000_00000000_10010000_00000000,
0b00000000_00000000_10010000_00000001,
0b00000000_00000000_10010000_00001000,
0b00000000_00000000_10010000_00001001,
0b00000000_00000000_10010000_01000000,
0b00000000_00000000_10010000_01000001,
0b00000000_00000000_10010000_01001000,
0b00000000_00000000_10010000_01001001,
0b00000000_00000000_10010010_00000000,
0b00000000_00000000_10010010_00000001,
0b00000000_00000000_10010010_00001000,
0b00000000_00000000_10010010_00001001,
0b00000000_00000000_10010010_01000000,
0b00000000_00000000_10010010_01000001,
0b00000000_00000000_10010010_01001000,
0b00000000_00000000_10010010_01001001,
0b00000000_00000100_00000000_00000000,
0b00000000_00000100_00000000_00000001,
0b00000000_00000100_00000000_00001000,
0b00000000_00000100_00000000_00001001,
0b00000000_00000100_00000000_01000000,
0b00000000_00000100_00000000_01000001,
0b00000000_00000100_00000000_01001000,
0b00000000_00000100_00000000_01001001,
0b00000000_00000100_00000010_00000000,
0b00000000_00000100_00000010_00000001,
0b00000000_00000100_00000010_00001000,
0b00000000_00000100_00000010_00001001,
0b00000000_00000100_00000010_01000000,
0b00000000_00000100_00000010_01000001,
0b00000000_00000100_00000010_01001000,
0b00000000_00000100_00000010_01001001,
0b00000000_00000100_00010000_00000000,
0b00000000_00000100_00010000_00000001,
0b00000000_00000100_00010000_00001000,
0b00000000_00000100_00010000_00001001,
0b00000000_00000100_00010000_01000000,
0b00000000_00000100_00010000_01000001,
0b00000000_00000100_00010000_01001000,
0b00000000_00000100_00010000_01001001,
0b00000000_00000100_00010010_00000000,
0b00000000_00000100_00010010_00000001,
0b00000000_00000100_00010010_00001000,
0b00000000_00000100_00010010_00001001,
0b00000000_00000100_00010010_01000000,
0b00000000_00000100_00010010_01000001,
0b00000000_00000100_00010010_01001000,
0b00000000_00000100_00010010_01001001,
0b00000000_00000100_10000000_00000000,
0b00000000_00000100_10000000_00000001,
0b00000000_00000100_10000000_00001000,
0b00000000_00000100_10000000_00001001,
0b00000000_00000100_10000000_01000000,
0b00000000_00000100_10000000_01000001,
0b00000000_00000100_10000000_01001000,
0b00000000_00000100_10000000_01001001,
0b00000000_00000100_10000010_00000000,
0b00000000_00000100_10000010_00000001,
0b00000000_00000100_10000010_00001000,
0b00000000_00000100_10000010_00001001,
0b00000000_00000100_10000010_01000000,
0b00000000_00000100_10000010_01000001,
0b00000000_00000100_10000010_01001000,
0b00000000_00000100_10000010_01001001,
0b00000000_00000100_10010000_00000000,
0b00000000_00000100_10010000_00000001,
0b00000000_00000100_10010000_00001000,
0b00000000_00000100_10010000_00001001,
0b00000000_00000100_10010000_01000000,
0b00000000_00000100_10010000_01000001,
0b00000000_00000100_10010000_01001000,
0b00000000_00000100_10010000_01001001,
0b00000000_00000100_10010010_00000000,
0b00000000_00000100_10010010_00000001,
0b00000000_00000100_10010010_00001000,
0b00000000_00000100_10010010_00001001,
0b00000000_00000100_10010010_01000000,
0b00000000_00000100_10010010_01000001,
0b00000000_00000100_10010010_01001000,
0b00000000_00000100_10010010_01001001,
0b00000000_00100000_00000000_00000000,
0b00000000_00100000_00000000_00000001,
0b00000000_00100000_00000000_00001000,
0b00000000_00100000_00000000_00001001,
0b00000000_00100000_00000000_01000000,
0b00000000_00100000_00000000_01000001,
0b00000000_00100000_00000000_01001000,
0b00000000_00100000_00000000_01001001,
0b00000000_00100000_00000010_00000000,
0b00000000_00100000_00000010_00000001,
0b00000000_00100000_00000010_00001000,
0b00000000_00100000_00000010_00001001,
0b00000000_00100000_00000010_01000000,
0b00000000_00100000_00000010_01000001,
0b00000000_00100000_00000010_01001000,
0b00000000_00100000_00000010_01001001,
0b00000000_00100000_00010000_00000000,
0b00000000_00100000_00010000_00000001,
0b00000000_00100000_00010000_00001000,
0b00000000_00100000_00010000_00001001,
0b00000000_00100000_00010000_01000000,
0b00000000_00100000_00010000_01000001,
0b00000000_00100000_00010000_01001000,
0b00000000_00100000_00010000_01001001,
0b00000000_00100000_00010010_00000000,
0b00000000_00100000_00010010_00000001,
0b00000000_00100000_00010010_00001000,
0b00000000_00100000_00010010_00001001,
0b00000000_00100000_00010010_01000000,
0b00000000_00100000_00010010_01000001,
0b00000000_00100000_00010010_01001000,
0b00000000_00100000_00010010_01001001,
0b00000000_00100000_10000000_00000000,
0b00000000_00100000_10000000_00000001,
0b00000000_00100000_10000000_00001000,
0b00000000_00100000_10000000_00001001,
0b00000000_00100000_10000000_01000000,
0b00000000_00100000_10000000_01000001,
0b00000000_00100000_10000000_01001000,
0b00000000_00100000_10000000_01001001,
0b00000000_00100000_10000010_00000000,
0b00000000_00100000_10000010_00000001,
0b00000000_00100000_10000010_00001000,
0b00000000_00100000_10000010_00001001,
0b00000000_00100000_10000010_01000000,
0b00000000_00100000_10000010_01000001,
0b00000000_00100000_10000010_01001000,
0b00000000_00100000_10000010_01001001,
0b00000000_00100000_10010000_00000000,
0b00000000_00100000_10010000_00000001,
0b00000000_00100000_10010000_00001000,
0b00000000_00100000_10010000_00001001,
0b00000000_00100000_10010000_01000000,
0b00000000_00100000_10010000_01000001,
0b00000000_00100000_10010000_01001000,
0b00000000_00100000_10010000_01001001,
0b00000000_00100000_10010010_00000000,
0b00000000_00100000_10010010_00000001,
0b00000000_00100000_10010010_00001000,
0b00000000_00100000_10010010_00001001,
0b00000000_00100000_10010010_01000000,
0b00000000_00100000_10010010_01000001,
0b00000000_00100000_10010010_01001000,
0b00000000_00100000_10010010_01001001,
0b00000000_00100100_00000000_00000000,
0b00000000_00100100_00000000_00000001,
0b00000000_00100100_00000000_00001000,
0b00000000_00100100_00000000_00001001,
0b00000000_00100100_00000000_01000000,
0b00000000_00100100_00000000_01000001,
0b00000000_00100100_00000000_01001000,
0b00000000_00100100_00000000_01001001,
0b00000000_00100100_00000010_00000000,
0b00000000_00100100_00000010_00000001,
0b00000000_00100100_00000010_00001000,
0b00000000_00100100_00000010_00001001,
0b00000000_00100100_00000010_01000000,
0b00000000_00100100_00000010_01000001,
0b00000000_00100100_00000010_01001000,
0b00000000_00100100_00000010_01001001,
0b00000000_00100100_00010000_00000000,
0b00000000_00100100_00010000_00000001,
0b00000000_00100100_00010000_00001000,
0b00000000_00100100_00010000_00001001,
0b00000000_00100100_00010000_01000000,
0b00000000_00100100_00010000_01000001,
0b00000000_00100100_00010000_01001000,
0b00000000_00100100_00010000_01001001,
0b00000000_00100100_00010010_00000000,
0b00000000_00100100_00010010_00000001,
0b00000000_00100100_00010010_00001000,
0b00000000_00100100_00010010_00001001,
0b00000000_00100100_00010010_01000000,
0b00000000_00100100_00010010_01000001,
0b00000000_00100100_00010010_01001000,
0b00000000_00100100_00010010_01001001,
0b00000000_00100100_10000000_00000000,
0b00000000_00100100_10000000_00000001,
0b00000000_00100100_10000000_00001000,
0b00000000_00100100_10000000_00001001,
0b00000000_00100100_10000000_01000000,
0b00000000_00100100_10000000_01000001,
0b00000000_00100100_10000000_01001000,
0b00000000_00100100_10000000_01001001,
0b00000000_00100100_10000010_00000000,
0b00000000_00100100_10000010_00000001,
0b00000000_00100100_10000010_00001000,
0b00000000_00100100_10000010_00001001,
0b00000000_00100100_10000010_01000000,
0b00000000_00100100_10000010_01000001,
0b00000000_00100100_10000010_01001000,
0b00000000_00100100_10000010_01001001,
0b00000000_00100100_10010000_00000000,
0b00000000_00100100_10010000_00000001,
0b00000000_00100100_10010000_00001000,
0b00000000_00100100_10010000_00001001,
0b00000000_00100100_10010000_01000000,
0b00000000_00100100_10010000_01000001,
0b00000000_00100100_10010000_01001000,
0b00000000_00100100_10010000_01001001,
0b00000000_00100100_10010010_00000000,
0b00000000_00100100_10010010_00000001,
0b00000000_00100100_10010010_00001000,
0b00000000_00100100_10010010_00001001,
0b00000000_00100100_10010010_01000000,
0b00000000_00100100_10010010_01000001,
0b00000000_00100100_10010010_01001000,
0b00000000_00100100_10010010_01001001,
}; // TODO figure out something for top byte
public int hashCode() {
int x = 0, y = 0, z = 0;
int lowX = x & 0xff;
int lowY = y & 0xff;
int lowZ = z & 0xff;
return lookupTable[lowX] | (lookupTable[lowZ] << 1) | (lookupTable[lowY] << 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment