public class LongArrayValueBitSet extends net.openhft.chronicle.core.io.AbstractCloseable implements Marshallable, ChronicleBitSet
ChronicleBitSet is intended to be shared between processes. To minimize locking constraints, it is implemented as a lock-free solution
without support for resizing.closedHere, DISABLE_DISCARD_WARNING, WARN_NSBITS_PER_WORDEMPTYDISCARD| Constructor and Description |
|---|
LongArrayValueBitSet(long maxNumberOfBits)
Constructs a new
LongArrayValueBitSet with the given maximum number of bits. |
LongArrayValueBitSet(long maxNumberOfBits,
Wire w)
Constructs a new
LongArrayValueBitSet with the given maximum number of bits and initializes it with the given Wire. |
| Modifier and Type | Method and Description |
|---|---|
void |
and(ChronicleBitSet set)
Performs a bitwise AND operation between this
ChronicleBitSet and the provided set. |
void |
andNot(ChronicleBitSet set)
Clears all the bits in this
ChronicleBitSet that are set in the specified ChronicleBitSet. |
int |
cardinality()
Computes the number of bits that are currently set to
true in this ChronicleBitSet. |
void |
clear()
Sets all bits in this ChronicleBitSet to
false. |
void |
clear(int bitIndex)
Clears (sets to
false) the bit specified by the index. |
void |
clear(int fromIndex,
int toIndex)
Clears (sets to
false) the range of bits from the specified starting index (inclusive) to the ending index (exclusive). |
void |
copyFrom(ChronicleBitSet bitSet) |
boolean |
equals(Object obj)
Compares this
ChronicleBitSet against the specified object. |
void |
flip(int bitIndex)
Flips the bit at the specified index, turning it to its opposite value (0 to 1, or 1 to 0).
|
void |
flip(int fromIndex,
int toIndex)
Flips the bits from a starting index to an ending index.
|
boolean |
get(int bitIndex)
Returns the value of the bit with the specified index.
|
long |
getWord(int wordIndex) |
int |
getWordsInUse()
Retrieves the number of words that are currently in use by this bit set.
|
int |
hashCode()
Returns the hash code for this
ChronicleBitSet. |
boolean |
intersects(ChronicleBitSet set)
Determines if there's any overlapping bit set to
true between this ChronicleBitSet and the given ChronicleBitSet. |
int |
nextClearBit(int fromIndex)
Retrieves the index of the first bit set to
false that occurs on or after the specified starting index. |
int |
nextSetBit(int fromIndex)
Finds and returns the index of the first bit that is set to
true after the specified starting index. |
int |
nextSetBit(int fromIndex,
int toIndex)
Retrieves the index of the first bit set to
true that occurs on or after the specified starting index
and before the specified ending index. |
void |
or(ChronicleBitSet set)
Performs a logical OR of this bit set with the bit set argument.
|
protected void |
performClose() |
int |
previousClearBit(int fromIndex)
Identifies the closest bit set to
false that occurs on or before the given starting index. |
int |
previousSetBit(int fromIndex)
Identifies the closest bit set to
true that occurs on or before the given starting index. |
void |
readMarshallable(@NotNull WireIn wire)
Reads the state of the Marshallable object from the given wire input.
|
void |
set(int bitIndex)
Sets the bit at the specified index to
true. |
void |
set(int bitIndex,
boolean value)
Sets or clears the bit at the specified index based on the provided boolean value.
|
void |
set(int fromIndex,
int toIndex)
Sets all bits in the specified range to
true. |
void |
set(int wordIndex,
long param,
net.openhft.chronicle.wire.LongArrayValueBitSet.LongFunction function)
Sets a specific word in this bit set using a provided function and parameter.
|
void |
set(net.openhft.chronicle.core.values.LongValue word,
long newValue)
Sets a new value for a given word in this bit set.
|
void |
setWord(int wordIndex,
long bits) |
int |
size()
Returns the total number of bits that this
ChronicleBitSet can represent. |
IntStream |
stream()
Returns an ordered stream of indices for which this
ChronicleBitSet contains a bit set to true. |
byte[] |
toByteArray()
Converts the bits in this bit set to a byte array.
|
String |
toString()
Returns a string representation of this bit set.
|
static BitSet |
valueOf(byte[] bytes)
Constructs and returns a new
BitSet using the bits from the provided byte array. |
void |
writeMarshallable(@NotNull WireOut wire)
Writes the state of the Marshallable object to the given wire output.
|
void |
xor(ChronicleBitSet set)
Performs a logical XOR of this bit set with the bit set argument.
|
assertCloseable, assertCloseablesClosed, close, createdHere, disableCloseableTracing, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, unmonitor, unmonitor, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosedclone, finalize, getClass, notify, notifyAll, wait, wait, waitisEmpty, length, set$equals, $fieldInfoMap, $fieldInfos, $hashCode, $toString, className, copyTo, deepCopy, fromFile, fromFile, fromString, fromString, fromString, getField, getLongField, mergeToMap, reset, setField, setLongField, streamFromFile, streamFromFilebinaryLengthLength, writeValueunexpectedFieldusesSelfDescribingMessageclose, closeQuietly, closeQuietlypublic LongArrayValueBitSet(long maxNumberOfBits)
LongArrayValueBitSet with the given maximum number of bits.maxNumberOfBits - Maximum number of bits that the bit set can handle.public LongArrayValueBitSet(long maxNumberOfBits,
Wire w)
LongArrayValueBitSet with the given maximum number of bits and initializes it with the given Wire.maxNumberOfBits - Maximum number of bits that the bit set can handle.w - The Wire object to be used for initialization.public static BitSet valueOf(byte[] bytes)
BitSet using the bits from the provided byte array.bytes - The byte array to be used for constructing the BitSet.BitSet containing all bits from the given byte array.public long getWord(int wordIndex)
getWord in interface ChronicleBitSetpublic void setWord(int wordIndex,
long bits)
setWord in interface ChronicleBitSetprotected void performClose()
performClose in class net.openhft.chronicle.core.io.AbstractCloseablepublic int getWordsInUse()
getWordsInUse in interface ChronicleBitSetpublic void set(int wordIndex,
long param,
net.openhft.chronicle.wire.LongArrayValueBitSet.LongFunction function)
wordIndex - The index of the word to set.param - The parameter to pass to the function.function - The function to compute the new word value based on the old value and the provided parameter.public void set(net.openhft.chronicle.core.values.LongValue word,
long newValue)
word - The LongValue instance representing the word to set.newValue - The new value to set for the word.public byte[] toByteArray()
public void flip(int bitIndex)
flip in interface ChronicleBitSetbitIndex - The index of the bit to flip.public void flip(int fromIndex,
int toIndex)
flip in interface ChronicleBitSetfromIndex - The starting index of the range, inclusive.toIndex - The ending index of the range, exclusive.public void set(int bitIndex)
true.set in interface ChronicleBitSetbitIndex - The index of the bit to be set.public void set(int bitIndex,
boolean value)
set in interface ChronicleBitSetbitIndex - The index of the bit to be modified.value - If true, the bit will be set; if false, the bit will be cleared.public void set(int fromIndex,
int toIndex)
true.set in interface ChronicleBitSetfromIndex - The starting index of the range, inclusive.toIndex - The ending index of the range, exclusive.public void clear(int bitIndex)
false) the bit specified by the index.
If the bit index is beyond the current words in use, the operation is ignored.clear in interface ChronicleBitSetbitIndex - The index of the bit to be cleared.public void clear(int fromIndex,
int toIndex)
false) the range of bits from the specified starting index (inclusive) to the ending index (exclusive).
The method adjusts ranges if necessary and ensures efficient clearing even for larger ranges.clear in interface ChronicleBitSetfromIndex - Starting index of the range (inclusive).toIndex - Ending index of the range (exclusive).public void clear()
false.
Post invocation, the ChronicleBitSet is effectively empty with no bits set to true.clear in interface ChronicleBitSetpublic boolean get(int bitIndex)
true if the bit with the index bitIndex is currently set in
this ChronicleBitSet; otherwise, the result is false.get in interface ChronicleBitSetbitIndex - the bit indexIndexOutOfBoundsException - if the specified index is negativepublic int nextSetBit(int fromIndex)
true after the specified starting index.
If no such bit exists then it returns -1.nextSetBit in interface ChronicleBitSetfromIndex - The index to start checking from (inclusive).public int nextSetBit(int fromIndex,
int toIndex)
true that occurs on or after the specified starting index
and before the specified ending index. If no such bit exists within the specified range, it returns -1.nextSetBit in interface ChronicleBitSetfromIndex - The index to start checking from (inclusive).toIndex - The index to stop checking at (exclusive).-1 if there's no set bit found.public int nextClearBit(int fromIndex)
false that occurs on or after the specified starting index.
If all bits are set to true after the specified index, it returns the length of this ChronicleBitSet.nextClearBit in interface ChronicleBitSetfromIndex - The index to start checking from (inclusive).public int previousSetBit(int fromIndex)
true that occurs on or before the given starting index.
If no such bit exists or if -1 is the starting index, the method returns -1.fromIndex - The index to start the reverse search from (inclusive).-1 if no set bit is found.public int previousClearBit(int fromIndex)
false that occurs on or before the given starting index.
If no such bit exists or if -1 is the starting index, the method returns -1.fromIndex - The index to start the reverse search from (inclusive).-1 if no clear bit is found.public boolean intersects(ChronicleBitSet set)
true between this ChronicleBitSet and the given ChronicleBitSet.intersects in interface ChronicleBitSetset - The ChronicleBitSet to compare against.true if there's an intersecting bit set to true between the two sets, false otherwise.public int cardinality()
true in this ChronicleBitSet.cardinality in interface ChronicleBitSettrue.public void and(ChronicleBitSet set)
ChronicleBitSet and the provided set.
After this operation, a bit will be set to true in this set only if it was already set to true and the corresponding bit in the provided set is true.and in interface ChronicleBitSetset - The ChronicleBitSet to perform the AND operation with.public void or(ChronicleBitSet set)
true
if and only if it either already had the value true or the corresponding bit in the bit set argument has the value true.or in interface ChronicleBitSetpublic void xor(ChronicleBitSet set)
true if and only if one of the following statements holds:
true, and the
corresponding bit in the argument has the value false.
false, and the
corresponding bit in the argument has the value true.
xor in interface ChronicleBitSetpublic void andNot(ChronicleBitSet set)
ChronicleBitSet that are set in the specified ChronicleBitSet.
In other words, for each bit set in the provided set, the corresponding bit in this set is cleared.andNot in interface ChronicleBitSetset - The ChronicleBitSet whose set bits will be used to clear the corresponding bits in this set.public int hashCode()
ChronicleBitSet. The hash code is calculated based on the set bits in this bit set.public int size()
ChronicleBitSet can represent. This includes both set and unset bits.size in interface ChronicleBitSetpublic boolean equals(Object obj)
ChronicleBitSet against the specified object.
The result is true if the object is a ChronicleBitSet and has the exact same set of bits set to true as this bit set.public String toString()
ChronicleBitSet contains a bit in the set state, the decimal
representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a
comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.toString in class net.openhft.chronicle.core.io.AbstractCloseablepublic IntStream stream()
ChronicleBitSet contains a bit set to true.
The indices are returned in ascending order. The size of the stream corresponds to the number of bits
set to true, which matches the value returned by the cardinality() method.public void writeMarshallable(@NotNull
@NotNull WireOut wire)
MarshallableThe default implementation will write all values even if they are a default value. c.f. readMarshallable
writeMarshallable in interface MarshallablewriteMarshallable in interface WriteMarshallablewire - The wire output destination.public void readMarshallable(@NotNull
@NotNull WireIn wire)
throws net.openhft.chronicle.core.io.IORuntimeException
MarshallableThe default implementation will use a default value for each field not present
readMarshallable in interface MarshallablereadMarshallable in interface ReadMarshallablewire - The wire input source.net.openhft.chronicle.core.io.IORuntimeException - If an IO error occurs during the read operation.public void copyFrom(ChronicleBitSet bitSet)
copyFrom in interface ChronicleBitSetCopyright © 2024. All rights reserved.