Package org.agrona.collections
Class Hashing
- java.lang.Object
-
- org.agrona.collections.Hashing
-
public final class Hashing extends java.lang.Object
Hashing functions for applying to integers.
-
-
Field Summary
Fields Modifier and Type Field Description static float
DEFAULT_LOAD_FACTOR
Default load factor to be used in open-addressing hashed data structures.
-
Constructor Summary
Constructors Modifier Constructor Description private
Hashing()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
compoundKey(int keyPartA, int keyPartB)
Combined two 32-bit keys into a 64-bit compound.static int
evenHash(int value, int mask)
Generate an even hash for an int value and apply mask to get a remainder that will be even.static int
evenHash(long value, int mask)
Generate an even hash for a long value and apply mask to get a remainder that will be even.static int
hash(int value)
Generate a hash for an int value.static int
hash(int value, int mask)
Generate a hash for an int value and apply mask to get remainder.static int
hash(long value)
Generate a hash for a long value.static int
hash(long value, int mask)
Generate a hash for a long value and apply mask to get a remainder.static int
hash(java.lang.Object value, int mask)
Generate a hash for an object and apply mask to get a remainder.
-
-
-
Field Detail
-
DEFAULT_LOAD_FACTOR
public static final float DEFAULT_LOAD_FACTOR
Default load factor to be used in open-addressing hashed data structures.- See Also:
- Constant Field Values
-
-
Method Detail
-
hash
public static int hash(int value)
Generate a hash for an int value.- Parameters:
value
- to be hashed.- Returns:
- the hashed value.
-
hash
public static int hash(long value)
Generate a hash for a long value.- Parameters:
value
- to be hashed.- Returns:
- the hashed value.
-
hash
public static int hash(int value, int mask)
Generate a hash for an int value and apply mask to get remainder.- Parameters:
value
- to be hashed.mask
- mask to be applied that must be a power of 2 - 1.- Returns:
- the hash of the value.
-
hash
public static int hash(java.lang.Object value, int mask)
Generate a hash for an object and apply mask to get a remainder.- Parameters:
value
- to be hashed.mask
- mask to be applied that must be a power of 2 - 1.- Returns:
- the hash of the value.
-
hash
public static int hash(long value, int mask)
Generate a hash for a long value and apply mask to get a remainder.- Parameters:
value
- to be hashed.mask
- mask to be applied that must be a power of 2 - 1.- Returns:
- the hash of the value.
-
evenHash
public static int evenHash(int value, int mask)
Generate an even hash for an int value and apply mask to get a remainder that will be even.- Parameters:
value
- to be hashed.mask
- mask to be applied that must be a power of 2 - 1.- Returns:
- the hash of the value which is always even.
-
evenHash
public static int evenHash(long value, int mask)
Generate an even hash for a long value and apply mask to get a remainder that will be even.- Parameters:
value
- to be hashed.mask
- mask to be applied that must be a power of 2 - 1.- Returns:
- the hash of the value which is always even.
-
compoundKey
public static long compoundKey(int keyPartA, int keyPartB)
Combined two 32-bit keys into a 64-bit compound.- Parameters:
keyPartA
- to make the upper bitskeyPartB
- to make the lower bits.- Returns:
- the compound key
-
-