java.lang.Object
speiger.src.collections.utils.HashUtil
Helper class that is used for HashMap functions reduce duplicated code
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final floatDefault HashMap Load Factorstatic final intMinimum HashMap Capacitystatic final intMinimum ConcurrentHashMap Concurrencystatic final floatHashMap Load Factor with reduced hash collisions but more memory usagestatic final floatHashMap Load Factor with minimal hash collisions but more memory usage -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic intarraySize(int size, float loadFactor) Helper function that creates the ideal array size for HashMapstatic intgetRequiredBits(int value) Function that finds out how many bits are required to store the number Providedstatic intgetRequiredBits(long value) Function that finds out how many bits are required to store the number Providedstatic intinvMix(int x) The inverse ofmix(int).static intmix(int x) Quickly mixes the bits of an integer.static intnextPowerOfTwo(int x) Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242static longnextPowerOfTwo(long x) Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242
-
Felddetails
-
DEFAULT_MIN_CAPACITY
public static final int DEFAULT_MIN_CAPACITYMinimum HashMap Capacity- Siehe auch:
-
DEFAULT_MIN_CONCURRENCY
public static final int DEFAULT_MIN_CONCURRENCYMinimum ConcurrentHashMap Concurrency- Siehe auch:
-
DEFAULT_LOAD_FACTOR
public static final float DEFAULT_LOAD_FACTORDefault HashMap Load Factor- Siehe auch:
-
FAST_LOAD_FACTOR
public static final float FAST_LOAD_FACTORHashMap Load Factor with reduced hash collisions but more memory usage- Siehe auch:
-
FASTER_LOAD_FACTOR
public static final float FASTER_LOAD_FACTORHashMap Load Factor with minimal hash collisions but more memory usage- Siehe auch:
-
-
Konstruktordetails
-
HashUtil
public HashUtil()
-
-
Methodendetails
-
mix
public static int mix(int x) Quickly mixes the bits of an integer.This method mixes the bits of the argument by multiplying by the golden ratio and xorshifting the result. It is borrowed from Koloboke,
- Parameter:
x- an integer.- Gibt zurück:
- a hash value obtained by mixing the bits of
x. - Siehe auch:
-
invMix
public static int invMix(int x) The inverse ofmix(int). This method is mainly useful to create unit tests.- Parameter:
x- an integer.- Gibt zurück:
- a value that passed through
mix(int)would givex.
-
nextPowerOfTwo
public static int nextPowerOfTwo(int x) Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242- Parameter:
x- that should be converted to the next power of two- Gibt zurück:
- the input number rounded up to the next power of two
-
nextPowerOfTwo
public static long nextPowerOfTwo(long x) Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242- Parameter:
x- that should be converted to the next power of two- Gibt zurück:
- the input number rounded up to the next power of two
-
getRequiredBits
public static int getRequiredBits(int value) Function that finds out how many bits are required to store the number Provided- Parameter:
value- to get the required bits to store.- Gibt zurück:
- the required bits to store that number
- Note:
- Really useful for compression. Reducing data that is inserted into a GZIP algorithm.
-
getRequiredBits
public static int getRequiredBits(long value) Function that finds out how many bits are required to store the number Provided- Parameter:
value- to get the required bits to store.- Gibt zurück:
- the required bits to store that number
- Note:
- Really useful for compression. Reducing data that is inserted into a GZIP algorithm.
-
arraySize
public static int arraySize(int size, float loadFactor) Helper function that creates the ideal array size for HashMap- Parameter:
size- the original array sizeloadFactor- the load factor- Gibt zurück:
- the new array size
-