public interface ChronicleBitSet extends Marshallable, net.openhft.chronicle.core.io.Closeable
Marshallable and
Closeable. Implementations may store state off-heap so that bits can
be persisted or shared between processes. Examples include
LongValueBitSet and LongArrayValueBitSet.| Modifier and Type | Field and Description |
|---|---|
static long |
BITS_PER_WORD
The number of bits in a
long word (64). |
EMPTYDISCARD| Modifier and Type | Method and Description |
|---|---|
void |
and(ChronicleBitSet bitSet)
Performs a logical AND with the given set.
|
void |
andNot(ChronicleBitSet bitSet)
Clears the bits that are set in the given set from this set.
|
int |
cardinality()
Counts the number of bits set to
true. |
void |
clear()
Sets all the bits in this ChronicleBitSet to
false. |
void |
clear(int bitIndex)
Clears the bit at the given zero-based index.
|
void |
clear(int fromIndex,
int toIndex)
Clears all bits in the range
[fromIndex, toIndex). |
void |
copyFrom(ChronicleBitSet bitSet)
Copies all bits from
bitSet into this set. |
void |
flip(int index)
Flips the state of the bit at
index. |
void |
flip(int fromIndex,
int toIndex)
Toggles all bits in the range
[fromIndex, toIndex). |
boolean |
get(int bitIndex)
Returns the value of the bit at the given zero-based index.
|
long |
getWord(int wordIndex)
Fetches the word at
wordIndex from the internal representation. |
int |
getWordsInUse()
Returns the number of
long words currently used to hold the bits. |
boolean |
intersects(ChronicleBitSet bitSet)
Checks whether any bit is set in both this set and
bitSet. |
default boolean |
isEmpty() |
default int |
length()
Returns the "logical size" of this
ChronicleBitSet: the index of the highest set bit in the ChronicleBitSet plus one. |
int |
nextClearBit(int index)
Returns the index of the next clear bit at or after
index. |
int |
nextSetBit(int fromIndex)
Finds the next set bit at or after
fromIndex. |
int |
nextSetBit(int fromIndex,
int toIndex)
Finds the index of the next set bit between
fromIndex and
toIndex inclusive. |
void |
or(ChronicleBitSet bitSet)
Performs a logical OR with the given set.
|
void |
set(int bitIndex)
Sets the bit at the given zero-based index.
|
default void |
set(int bitIndex,
boolean value)
Sets the bit at the given index to the provided value.
|
void |
set(int fromIndex,
int toIndex)
Sets every bit in the range
[fromIndex, toIndex) to
true. |
default void |
set(int fromIndex,
int toIndex,
boolean value)
Sets each bit in the range
[fromIndex, toIndex) to the given value. |
void |
setWord(int wordIndex,
long bits)
Sets the word at
wordIndex to bits. |
int |
size()
Returns the number of bits of space actually in use by this
ChronicleBitSet to represent bit values. |
void |
xor(ChronicleBitSet bitSet)
Performs a logical XOR with the given set.
|
$equals, $fieldInfoMap, $fieldInfos, $hashCode, $toString, className, copyTo, deepCopy, fromFile, fromFile, fromString, fromString, fromString, getField, getLongField, mergeToMap, readMarshallable, reset, setField, setLongField, streamFromFile, streamFromFile, writeMarshallablebinaryLengthLength, writeValueunexpectedFieldusesSelfDescribingMessagestatic final long BITS_PER_WORD
long word (64).int size()
ChronicleBitSet to represent bit values.
The maximum element in the set is the size - 1st element.void set(int bitIndex)
bitIndex - index of the bit to setIndexOutOfBoundsException - if bitIndex < 0default void set(int bitIndex,
boolean value)
bitIndex - zero-based index of the bit to modifyvalue - the value to store at that indexIndexOutOfBoundsException - if bitIndex < 0void set(int fromIndex,
int toIndex)
[fromIndex, toIndex) to
true.fromIndex - index of the first bit to set, zero-basedtoIndex - index after the last bit to setIndexOutOfBoundsException - if an index is negative or the range
is invaliddefault void set(int fromIndex,
int toIndex,
boolean value)
[fromIndex, toIndex) to the given value.fromIndex - zero-based index of the first bit to modifytoIndex - index after the last bit to modifyvalue - value to store in the selected rangeIndexOutOfBoundsException - if an index is negative or the range is invalidboolean get(int bitIndex)
bitIndex - index of the bit to querytrue if the bit is setIndexOutOfBoundsException - if bitIndex < 0void clear(int bitIndex)
bitIndex - index of the bit to clearIndexOutOfBoundsException - if bitIndex < 0int nextSetBit(int fromIndex,
int toIndex)
fromIndex and
toIndex inclusive.
To iterate over the true bits in a ChronicleBitSet,
use the following loop:
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1,to)) {
// operate on index i here
if (i == Integer.MAX_VALUE) {
break; // or (i+1) would overflow
}
}fromIndex - zero-based index to begin searching (inclusive)toIndex - maximum index to examine (inclusive)-1 if none is foundIndexOutOfBoundsException - if an index is negativeint nextSetBit(int fromIndex)
fromIndex.fromIndex - zero-based index to begin searching-1 if none is foundIndexOutOfBoundsException - if fromIndex < 0void clear()
false.default boolean isEmpty()
default int length()
ChronicleBitSet: the index of the highest set bit in the ChronicleBitSet plus one.
Returns zero if the ChronicleBitSet contains no set bits.ChronicleBitSetint cardinality()
true.int nextClearBit(int index)
index.index - zero-based starting position-1 if none is foundIndexOutOfBoundsException - if index < 0void flip(int index)
index.index - zero-based index of the bit to flipIndexOutOfBoundsException - if index < 0void flip(int fromIndex,
int toIndex)
[fromIndex, toIndex).fromIndex - zero-based start of the rangetoIndex - end of the range (exclusive)IndexOutOfBoundsException - if the range is invalidvoid clear(int fromIndex,
int toIndex)
[fromIndex, toIndex).fromIndex - zero-based start of the rangetoIndex - end of the range (exclusive)IndexOutOfBoundsException - if the range is invalidint getWordsInUse()
long words currently used to hold the bits.
Trailing zero words are not counted.long getWord(int wordIndex)
wordIndex from the internal representation.wordIndex - zero-based index of the word0 if out of rangevoid setWord(int wordIndex,
long bits)
wordIndex to bits. Implementations may
extend the storage to accommodate the index.wordIndex - zero-based index of the word to modifybits - the 64 bits to storevoid andNot(ChronicleBitSet bitSet)
bitSet - bit set defining the bits to clearvoid and(ChronicleBitSet bitSet)
bitSet - other bit setvoid xor(ChronicleBitSet bitSet)
bitSet - other bit setvoid or(ChronicleBitSet bitSet)
bitSet - other bit setboolean intersects(ChronicleBitSet bitSet)
bitSet.bitSet - other bit settrue if the sets share a common set bitvoid copyFrom(ChronicleBitSet bitSet)
bitSet into this set.bitSet - source bit setCopyright © 2026 Chronicle Software Ltd. All rights reserved.