Modifier  Constructor and Description 

protected 
HashCommon() 
Modifier and Type  Method and Description 

static int 
arraySize(int expected,
float f)
Returns the least power of two smaller than or equal to 2^{30} and larger than or equal
to
Math.ceil(expected / f) . 
static long 
bigArraySize(long expected,
float f)
Returns the least power of two larger than or equal to
Math.ceil(expected / f) . 
static int 
double2int(double d)
Returns the hash code that would be returned by
Double.hashCode() . 
static int 
float2int(float f)
Returns the hash code that would be returned by
Float.hashCode() . 
static int 
invMix(int x)
The inverse of
mix(int) . 
static long 
invMix(long x)
The inverse of
mix(long) . 
static int 
long2int(long l)
Returns the hash code that would be returned by
Long.hashCode() . 
static int 
maxFill(int n,
float f)
Returns the maximum number of entries that can be filled before rehashing.

static long 
maxFill(long n,
float f)
Returns the maximum number of entries that can be filled before rehashing.

static int 
mix(int x)
Quickly mixes the bits of an integer.

static long 
mix(long x)
Quickly mixes the bits of a long integer.

static int 
murmurHash3(int x)
Avalanches the bits of an integer by applying the finalisation step of MurmurHash3.

static long 
murmurHash3(long x)
Avalanches the bits of a long integer by applying the finalisation step of MurmurHash3.

static int 
nextPowerOfTwo(int x)
Returns the least power of two greater than or equal to the specified value.

static long 
nextPowerOfTwo(long x)
Returns the least power of two greater than or equal to the specified value.

public static int murmurHash3(int x)
This method implements the finalisation step of Austin Appleby's MurmurHash3. Its purpose is to avalanche the bits of the argument to within 0.25% bias.
x
 an integer.public static long murmurHash3(long x)
This method implements the finalisation step of Austin Appleby's MurmurHash3. Its purpose is to avalanche the bits of the argument to within 0.25% bias.
x
 a long integer.public static int mix(int x)
This method mixes the bits of the argument by multiplying by the golden ratio and
xorshifting the result. It is borrowed from Koloboke, and it has slightly worse behaviour
than murmurHash3(int)
(in openaddressing hash tables the average number of probes is
slightly larger), but it's much faster.
x
 an integer.x
.invMix(int)
public static int invMix(int x)
mix(int)
. This method is mainly useful to create unit tests.x
 an integer.mix(int)
would give x
.public static long mix(long x)
This method mixes the bits of the argument by multiplying by the golden ratio and
xorshifting twice the result. It is borrowed from Koloboke, and it has slightly worse behaviour
than murmurHash3(long)
(in openaddressing hash tables the average number of probes is
slightly larger), but it's much faster.
x
 a long integer.x
.public static long invMix(long x)
mix(long)
. This method is mainly useful to create unit tests.x
 a long integer.mix(long)
would give x
.public static int float2int(float f)
Float.hashCode()
.f
 a float.new Float(f).hashCode()
.public static int double2int(double d)
Double.hashCode()
.d
 a double.new Double(f).hashCode()
.public static int long2int(long l)
Long.hashCode()
.l
 a long.new Long(f).hashCode()
.public static int nextPowerOfTwo(int x)
Note that this function will return 1 when the argument is 0.
x
 an integer smaller than or equal to 2^{30}.public static long nextPowerOfTwo(long x)
Note that this function will return 1 when the argument is 0.
x
 a long integer smaller than or equal to 2^{62}.public static int maxFill(int n, float f)
n
 the size of the backing array.f
 the load factor.public static long maxFill(long n, float f)
n
 the size of the backing array.f
 the load factor.public static int arraySize(int expected, float f)
Math.ceil(expected / f)
.expected
 the expected number of elements in a hash table.f
 the load factor.java.lang.IllegalArgumentException
 if the necessary size is larger than 2^{30}.public static long bigArraySize(long expected, float f)
Math.ceil(expected / f)
.expected
 the expected number of elements in a hash table.f
 the load factor.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.