@Test public void testHash32ByteArrayInt() { for (int i = 0; i < input.length; i++) { int hash = MurmurHash.hash32(input[i], input[i].length); if (hash != results32_standard[i]) { fail(String.format( "Unexpected hash32 result for example %d: 0x%08x instead of 0x%08x", i, hash, results32_standard[i])); } } }
public static int hash32(final byte[] data, int length, int seed) { final int m = 0x5bd1e995; final int r = 24; int h = seed ^ length; int length4 = length / 4; for (int i = 0; i < length4; i++) { final int i4 = i * 4; int k = (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + ((data[i4 + 2] & 0xff) << 16) + ((data[i4 + 3] & 0xff) << 24); k *= m; k ^= k >>> r; k *= m; h *= m; h ^= k; } switch (length % 4) { case 3: h ^= (data[(length & ~3) + 2] & 0xff) << 16; case 2: h ^= (data[(length & ~3) + 1] & 0xff) << 8; case 1: h ^= (data[length & ~3] & 0xff); h *= m; default: } h ^= h >>> 13; h *= m; h ^= h >>> 15; return h; }
MurmurHash { public static int hash32(final byte[] data, int length, int seed) { final int m = 0x5bd1e995; final int r = 24; int h = seed ^ length; int length4 = length / 4; for (int i = 0; i < length4; i++) { final int i4 = i * 4; int k = (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + ((data[i4 + 2] & 0xff) << 16) + ((data[i4 + 3] & 0xff) << 24); k *= m; k ^= k >>> r; k *= m; h *= m; h ^= k; } switch (length % 4) { case 3: h ^= (data[(length & ~3) + 2] & 0xff) << 16; case 2: h ^= (data[(length & ~3) + 1] & 0xff) << 8; case 1: h ^= (data[length & ~3] & 0xff); h *= m; default: } h ^= h >>> 13; h *= m; h ^= h >>> 15; return h; } }
MurmurHash { public static int hash32(final byte[] data, int length, int seed) { final int m = 0x5bd1e995; final int r = 24; int h = seed ^ length; int length4 = length / 4; for (int i = 0; i < length4; i++) { final int i4 = i * 4; int k = (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + ((data[i4 + 2] & 0xff) << 16) + ((data[i4 + 3] & 0xff) << 24); k *= m; k ^= k >>> r; k *= m; h *= m; h ^= k; } switch (length % 4) { case 3: h ^= (data[(length & ~3) + 2] & 0xff) << 16; case 2: h ^= (data[(length & ~3) + 1] & 0xff) << 8; case 1: h ^= (data[length & ~3] & 0xff); h *= m; default: } h ^= h >>> 13; h *= m; h ^= h >>> 15; return h; } private  MurmurHash(); }
MurmurHash { public static int hash32(final byte[] data, int length, int seed) { final int m = 0x5bd1e995; final int r = 24; int h = seed ^ length; int length4 = length / 4; for (int i = 0; i < length4; i++) { final int i4 = i * 4; int k = (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + ((data[i4 + 2] & 0xff) << 16) + ((data[i4 + 3] & 0xff) << 24); k *= m; k ^= k >>> r; k *= m; h *= m; h ^= k; } switch (length % 4) { case 3: h ^= (data[(length & ~3) + 2] & 0xff) << 16; case 2: h ^= (data[(length & ~3) + 1] & 0xff) << 8; case 1: h ^= (data[length & ~3] & 0xff); h *= m; default: } h ^= h >>> 13; h *= m; h ^= h >>> 15; return h; } private  MurmurHash(); static int hash32(final byte[] data, int length, int seed); static int hash32(final byte[] data, int length); static int hash32(final String text); static int hash32(final String text, int from, int length); static long hash64(final byte[] data, int length, int seed); static long hash64(final byte[] data, int length); static long hash64(final String text); static long hash64(final String text, int from, int length); static long hash64(String first, String... rest); }
MurmurHash { public static int hash32(final byte[] data, int length, int seed) { final int m = 0x5bd1e995; final int r = 24; int h = seed ^ length; int length4 = length / 4; for (int i = 0; i < length4; i++) { final int i4 = i * 4; int k = (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + ((data[i4 + 2] & 0xff) << 16) + ((data[i4 + 3] & 0xff) << 24); k *= m; k ^= k >>> r; k *= m; h *= m; h ^= k; } switch (length % 4) { case 3: h ^= (data[(length & ~3) + 2] & 0xff) << 16; case 2: h ^= (data[(length & ~3) + 1] & 0xff) << 8; case 1: h ^= (data[length & ~3] & 0xff); h *= m; default: } h ^= h >>> 13; h *= m; h ^= h >>> 15; return h; } private  MurmurHash(); static int hash32(final byte[] data, int length, int seed); static int hash32(final byte[] data, int length); static int hash32(final String text); static int hash32(final String text, int from, int length); static long hash64(final byte[] data, int length, int seed); static long hash64(final byte[] data, int length); static long hash64(final String text); static long hash64(final String text, int from, int length); static long hash64(String first, String... rest);  }