public final class HashUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
computePerturbationValue(int capacity)
Compute the key perturbation value applied before hashing.
|
static int |
fastIntMix(int k) |
static long |
fastLongMix(long k) |
static int |
hashCode(Object... objects)
Hash code for multiple objects using
Arrays.hashCode(Object[]). |
static int |
hashToIndex(int hash,
int length)
A function that calculates the index (e.g.
|
static int |
MurmurHash3_fmix(int k) |
static long |
MurmurHash3_fmix(long k) |
static long |
MurmurHash3_x64_64_direct(long address,
int offset,
int len) |
static long |
MurmurHash3_x64_64_direct(long address,
int offset,
int len,
int seed) |
static long |
MurmurHash3_x64_64(byte[] data,
int offset,
int len) |
static long |
MurmurHash3_x64_64(byte[] data,
int offset,
int len,
int seed) |
static int |
MurmurHash3_x86_32_direct(long address,
int offset,
int len) |
static int |
MurmurHash3_x86_32_direct(long address,
int offset,
int len,
int seed)
Returns the MurmurHash3_x86_32 hash.
|
static int |
MurmurHash3_x86_32(byte[] data,
int offset,
int len) |
static int |
MurmurHash3_x86_32(byte[] data,
int offset,
int len,
int seed)
Returns the MurmurHash3_x86_32 hash.
|
public static int MurmurHash3_x86_32(byte[] data,
int offset,
int len)
public static int MurmurHash3_x86_32(byte[] data,
int offset,
int len,
int seed)
public static int MurmurHash3_x86_32_direct(long address,
int offset,
int len)
public static int MurmurHash3_x86_32_direct(long address,
int offset,
int len,
int seed)
public static long MurmurHash3_x64_64(byte[] data,
int offset,
int len)
public static long MurmurHash3_x64_64(byte[] data,
int offset,
int len,
int seed)
public static long MurmurHash3_x64_64_direct(long address,
int offset,
int len)
public static long MurmurHash3_x64_64_direct(long address,
int offset,
int len,
int seed)
public static int MurmurHash3_fmix(int k)
public static long MurmurHash3_fmix(long k)
public static long fastLongMix(long k)
public static int fastIntMix(int k)
public static int hashCode(Object... objects)
Arrays.hashCode(Object[]).public static int hashToIndex(int hash,
int length)
length - the length of the array/listIllegalArgumentException - if mod smaller than 1.public static int computePerturbationValue(int capacity)
Compute the key perturbation value applied before hashing. The returned value should be non-zero and ideally different for each capacity. This matters because keys are nearly-ordered by their hashed values so when adding one container's values to the other, the number of collisions can skyrocket into the worst case possible.
If it is known that hash containers will not be added to each other (will be used for counting only, for example) then some speed can be gained by not perturbing keys before hashing and returning a value of zero for all possible capacities. The speed gain is a result of faster rehash operation (keys are mostly in order).
Copyright © 2016. All Rights Reserved.