| 43 |
private static long BYTE_MASK = 0x00000000000000ffL; |
private static long BYTE_MASK = 0x00000000000000ffL; |
| 44 |
|
|
| 45 |
private static long rot(long val, int pos) { |
private static long rot(long val, int pos) { |
| 46 |
return ((long)(Integer.rotateLeft( |
return ((Integer.rotateLeft( |
| 47 |
(int)(val & INT_MASK), pos)) & INT_MASK); |
(int)(val & INT_MASK), pos)) & INT_MASK); |
| 48 |
} |
} |
| 49 |
|
|
| 93 |
* <p>Use for hash table lookup, or anything where one collision in 2^^32 is |
* <p>Use for hash table lookup, or anything where one collision in 2^^32 is |
| 94 |
* acceptable. Do NOT use for cryptographic purposes. |
* acceptable. Do NOT use for cryptographic purposes. |
| 95 |
*/ |
*/ |
| 96 |
|
@SuppressWarnings("fallthrough") |
| 97 |
public static int hash(byte[] key, int nbytes, int initval) { |
public static int hash(byte[] key, int nbytes, int initval) { |
| 98 |
int length = nbytes; |
int length = nbytes; |
| 99 |
long a, b, c; // We use longs because we don't have unsigned ints |
long a, b, c; // We use longs because we don't have unsigned ints |