Package org.neo4j.gds.core.utils.paged
Class HugeAtomicBitSet
- java.lang.Object
-
- org.neo4j.gds.core.utils.paged.HugeAtomicBitSet
-
- Direct Known Subclasses:
HugeAtomicGrowingBitSet
public class HugeAtomicBitSet extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected HugeAtomicLongArray
bits
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allSet()
Returns true iff all bits are set.long
cardinality()
Returns the number of set bits in the bit set.void
clear()
Resets all bits in the bit set.void
clear(long index)
Resets the bit at the given index.static HugeAtomicBitSet
fixed(long size, AllocationTracker allocationTracker)
void
flip(long index)
Toggles the bit at the given index.void
forEachSetBit(java.util.function.LongConsumer consumer)
Iterates the bit set in increasing order and calls the given consumer for each set bit.boolean
get(long index)
Returns the state of the bit at the given index.boolean
getAndSet(long index)
Sets a bit and returns the previous value.static HugeAtomicBitSet
growing(long size, AllocationTracker allocationTracker)
boolean
isEmpty()
Returns true iff no bit is set.static long
memoryEstimation(long size)
void
set(long index)
Sets the bit at the given index to true.void
set(long startIndex, long endIndex)
Sets the bits from the startIndex (inclusive) to the endIndex (exclusive).long
size()
Returns the number of bits in the bitset.
-
-
-
Field Detail
-
bits
protected HugeAtomicLongArray bits
-
-
Method Detail
-
memoryEstimation
public static long memoryEstimation(long size)
-
fixed
public static HugeAtomicBitSet fixed(long size, AllocationTracker allocationTracker)
-
growing
public static HugeAtomicBitSet growing(long size, AllocationTracker allocationTracker)
-
get
public boolean get(long index)
Returns the state of the bit at the given index.
-
set
public void set(long index)
Sets the bit at the given index to true.
-
set
public void set(long startIndex, long endIndex)
Sets the bits from the startIndex (inclusive) to the endIndex (exclusive).
-
getAndSet
public boolean getAndSet(long index)
Sets a bit and returns the previous value. The index should be less than the BitSet size.
-
flip
public void flip(long index)
Toggles the bit at the given index.
-
forEachSetBit
public void forEachSetBit(java.util.function.LongConsumer consumer)
Iterates the bit set in increasing order and calls the given consumer for each set bit. This method is not thread-safe.
-
cardinality
public long cardinality()
Returns the number of set bits in the bit set.Note: this method is not thread-safe.
-
isEmpty
public boolean isEmpty()
Returns true iff no bit is set.Note: this method is not thread-safe.
-
allSet
public boolean allSet()
Returns true iff all bits are set.Note: this method is not thread-safe.
-
size
public long size()
Returns the number of bits in the bitset.
-
clear
public void clear()
Resets all bits in the bit set.Note: this method is not thread-safe.
-
clear
public void clear(long index)
Resets the bit at the given index.
-
-