public class HashUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static float |
DEFAULT_LOAD_FACTOR
Default HashMap Load Factor
|
static int |
DEFAULT_MIN_CAPACITY
Minimum HashMap Capacity
|
static int |
DEFAULT_MIN_CONCURRENCY
Minimum ConcurrentHashMap Concurrency
|
static float |
FAST_LOAD_FACTOR
HashMap Load Factor with reduced hash collisions but more memory usage
|
static float |
FASTER_LOAD_FACTOR
HashMap Load Factor with minimal hash collisions but more memory usage
|
| Constructor and Description |
|---|
HashUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
arraySize(int size,
float loadFactor)
Helper function that creates the ideal array size for HashMap
|
static int |
getRequiredBits(int value)
Function that finds out how many bits are required to store the number Provided
|
static int |
getRequiredBits(long value)
Function that finds out how many bits are required to store the number Provided
|
static int |
invMix(int x)
The inverse of
mix(int). |
static int |
mix(int x)
Quickly mixes the bits of an integer.
|
static int |
nextPowerOfTwo(int x)
Function that rounds up to the closest power of 2
A modified version of https://stackoverflow.com/a/466242
|
static long |
nextPowerOfTwo(long x)
Function that rounds up to the closest power of 2
A modified version of https://stackoverflow.com/a/466242
|
public static final int DEFAULT_MIN_CAPACITY
public static final int DEFAULT_MIN_CONCURRENCY
public static final float DEFAULT_LOAD_FACTOR
public static final float FAST_LOAD_FACTOR
public static final float FASTER_LOAD_FACTOR
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,
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 int nextPowerOfTwo(int x)
x - that should be converted to the next power of twopublic static long nextPowerOfTwo(long x)
x - that should be converted to the next power of twopublic static int getRequiredBits(int value)
value - to get the required bits to store.public static int getRequiredBits(long value)
value - to get the required bits to store.public static int arraySize(int size,
float loadFactor)
size - the original array sizeloadFactor - the load factor