Class BitmaskMath
java.lang.Object
org.javimmutable.collections.common.BitmaskMath
Helper class with static methods to manipulate long bitmasks.
Used in array map trie calculations.
Methods are short to allow inlining.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
addBit
(long bitmask, long bit) static int
arrayIndexForBit
(long bitmask, long bit) static int
bitCount
(long bitmask) static long
bitFromIndex
(int index) static boolean
bitIsAbsent
(long bitmask, long bit) static boolean
bitIsPresent
(long bitmask, long bit) static long
bitmask
(int... indices) static <S,
D> void copyToCompactArrayUsingBitmask
(long bitmask, S[] source, D[] dest, java.util.function.Function<S, D> transforminator) static void
forEachIndex
(long bitmask, java.util.function.IntConsumer proc) static int
indexForBit
(long bit) indices
(long bitmask) static long
leastBit
(long bitmask) static long
removeBit
(long bitmask, long bit)
-
Field Details
-
ARRAY_SIZE
public static final int ARRAY_SIZE- See Also:
-
MAX_INDEX
public static final int MAX_INDEX- See Also:
-
ALL_BITS
public static final long ALL_BITS- See Also:
-
-
Method Details
-
bitFromIndex
public static long bitFromIndex(int index) -
bitIsAbsent
public static boolean bitIsAbsent(long bitmask, long bit) -
bitIsPresent
public static boolean bitIsPresent(long bitmask, long bit) -
addBit
public static long addBit(long bitmask, long bit) -
removeBit
public static long removeBit(long bitmask, long bit) -
leastBit
public static long leastBit(long bitmask) -
indexForBit
public static int indexForBit(long bit) -
arrayIndexForBit
public static int arrayIndexForBit(long bitmask, long bit) -
bitCount
public static int bitCount(long bitmask) -
indices
-
forEachIndex
public static void forEachIndex(long bitmask, java.util.function.IntConsumer proc) -
copyToCompactArrayUsingBitmask
-
bitmask
public static long bitmask(int... indices)
-