public class LongValueBitSet extends net.openhft.chronicle.core.io.AbstractCloseable implements Marshallable, ChronicleBitSet
closedHere, DISABLE_DISCARD_WARNING, WARN_NSBITS_PER_WORDEMPTYDISCARD| Constructor and Description |
|---|
LongValueBitSet(int maxNumberOfBits)
Constructor that initializes a LongValueBitSet with a maximum number of bits provided as an integer.
|
LongValueBitSet(int maxNumberOfBits,
Wire w)
Constructor that initializes a LongValueBitSet with a maximum number of bits provided as an integer and associates it with a Wire.
|
LongValueBitSet(long maxNumberOfBits)
Constructor that initializes a LongValueBitSet with a maximum number of bits provided as a long.
|
LongValueBitSet(long maxNumberOfBits,
Wire w)
Constructor that initializes a LongValueBitSet with a maximum number of bits provided as a long and associates it with a Wire.
|
| Modifier and Type | Method and Description |
|---|---|
void |
and(ChronicleBitSet set)
Performs a logical AND operation between this
ChronicleBitSet and the specified ChronicleBitSet. |
void |
and(LongValueBitSet set)
Performs a logical AND operation between this
ChronicleBitSet and the specified LongValueBitSet. |
void |
andNot(ChronicleBitSet set)
Clears all the bits in this
ChronicleBitSet where the corresponding bit is set in the specified ChronicleBitSet. |
void |
andNot(LongValueBitSet set)
Clears all the bits in this
ChronicleBitSet where the corresponding bit is set in the specified LongValueBitSet. |
int |
cardinality()
Calculates and returns the number of bits set to
true in this ChronicleBitSet. |
void |
clear()
Sets all of the bits in this ChronicleBitSet to
false. |
void |
clear(int bitIndex)
Sets the bit specified by the index to
false. |
void |
clear(int fromIndex,
int toIndex)
Sets the bits from the specified
fromIndex (inclusive) to the specified toIndex (exclusive) to false. |
void |
copyFrom(ChronicleBitSet bitSet) |
boolean |
equals(Object obj)
Compares this
ChronicleBitSet object against the specified object. |
void |
flip(int bitIndex)
Flips the bit at the specified index, toggling it from its current value.
|
void |
flip(int fromIndex,
int toIndex)
Flips a range of bits, toggling them from their current value.
|
boolean |
get(int bitIndex)
Returns the value of the bit with the specified index.
|
long |
getWord(int wordIndex) |
int |
getWordsInUse()
Fetches the number of words currently in use in this BitSet.
|
int |
hashCode()
Computes the hash code for this
ChronicleBitSet. |
boolean |
intersects(ChronicleBitSet set)
Checks if the current
ChronicleBitSet has any common set bits with the specified ChronicleBitSet. |
boolean |
intersects(LongValueBitSet set)
Checks if the current
ChronicleBitSet intersects with the provided LongValueBitSet. |
int |
nextClearBit(int fromIndex)
Returns the index of the first bit that is set to
false that occurs on or after the specified starting index. |
int |
nextSetBit(int fromIndex)
Returns the index of the first bit that is set to
true that occurs on or after the specified starting index. |
int |
nextSetBit(int fromIndex,
int toIndex)
Returns the index of the first bit that is set to
true that occurs on or after the specified starting index but before the toIndex. |
void |
or(ChronicleBitSet set)
Executes a logical OR operation between this
ChronicleBitSet and the provided ChronicleBitSet. |
void |
or(LongValueBitSet set)
Performs a logical OR operation between this
ChronicleBitSet and the provided LongValueBitSet. |
protected void |
performClose() |
int |
previousClearBit(int fromIndex)
This method searches for the closest bit set to
false from the specified starting index moving backwards. |
int |
previousSetBit(int fromIndex)
This method searches for the closest bit set to
true from the specified starting index moving backwards. |
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 the bit at the specified index to the specified value.
|
void |
set(int fromIndex,
int toIndex)
Sets the bits from the specified
fromIndex (inclusive) to the specified toIndex (exclusive) to true. |
void |
set(int fromIndex,
int toIndex,
boolean value)
Sets the bits from the specified
fromIndex (inclusive) to the specified toIndex (exclusive) to the specified value. |
void |
set(net.openhft.chronicle.core.values.LongValue word,
long newValue)
Atomically sets the value of a LongValue object to a new value.
|
void |
set(net.openhft.chronicle.core.values.LongValue word,
long param,
net.openhft.chronicle.wire.LongValueBitSet.LongFunction function)
Atomically sets the value of a LongValue object based on a provided function and parameter.
|
void |
setWord(int wordIndex,
long bits) |
int |
size()
Retrieves the number of bits that are actually being used by this
ChronicleBitSet to represent bit values. |
IntStream |
stream()
Returns a stream of indices for which this
ChronicleBitSet contains a bit in the set state. |
byte[] |
toByteArray()
Converts the bit set to a byte array representation.
|
String |
toString()
Returns a string representation of this bit set.
|
static BitSet |
valueOf(byte[] bytes)
Creates a new BitSet from a given 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.
|
void |
xor(LongValueBitSet set)
Performs a logical XOR operation between this
ChronicleBitSet and the specified LongValueBitSet. |
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$equals, $fieldInfoMap, $fieldInfos, $hashCode, $toString, className, copyTo, deepCopy, fromFile, fromFile, fromString, fromString, fromString, getField, getLongField, mergeToMap, reset, setField, setLongField, streamFromFile, streamFromFilebinaryLengthLength, writeValueunexpectedFieldusesSelfDescribingMessageclose, closeQuietly, closeQuietlypublic LongValueBitSet(int maxNumberOfBits)
maxNumberOfBits - The maximum number of bits this BitSet can accommodate.public LongValueBitSet(int maxNumberOfBits,
Wire w)
maxNumberOfBits - The maximum number of bits this BitSet can accommodate.w - The Wire associated with this BitSet.public LongValueBitSet(long maxNumberOfBits)
maxNumberOfBits - The maximum number of bits this BitSet can accommodate.public LongValueBitSet(long maxNumberOfBits,
Wire w)
maxNumberOfBits - The maximum number of bits this BitSet can accommodate.w - The Wire associated with this BitSet.public static BitSet valueOf(byte[] bytes)
bytes - The byte array containing the bits.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(net.openhft.chronicle.core.values.LongValue word,
long param,
net.openhft.chronicle.wire.LongValueBitSet.LongFunction function)
word - The LongValue object whose value needs to be set.param - The parameter to pass to the function.function - A function that takes the old value of the word and the provided parameter to produce a new value.public void set(net.openhft.chronicle.core.values.LongValue word,
long newValue)
word - The LongValue object whose value needs to be set.newValue - The new value to be set.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 - Index of the first bit to flip (inclusive).toIndex - Index of the last bit to flip (exclusive).public void set(int bitIndex)
true.set in interface ChronicleBitSetbitIndex - The index of the bit to be set to true.public void set(int bitIndex,
boolean value)
true, the bit is set to 1, otherwise it is set to 0.set in interface ChronicleBitSetbitIndex - The index of the bit to be modified.value - The new value for the specified bit.public void set(int fromIndex,
int toIndex)
fromIndex (inclusive) to the specified toIndex (exclusive) to true.set in interface ChronicleBitSetpublic void set(int fromIndex,
int toIndex,
boolean value)
fromIndex (inclusive) to the specified toIndex (exclusive) to the specified value.set in interface ChronicleBitSetfromIndex - index of the first bit to be settoIndex - index after the last bit to be setvalue - value to set the selected bits toIndexOutOfBoundsException - if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndexpublic void clear(int bitIndex)
false.clear in interface ChronicleBitSetbitIndex - the index of the bit to be clearedpublic void clear(int fromIndex,
int toIndex)
fromIndex (inclusive) to the specified toIndex (exclusive) to false.clear in interface ChronicleBitSetpublic void clear()
false.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 index of the bit to checkpublic int nextSetBit(int fromIndex)
true that occurs on or after the specified starting index.
If no such bit exists then -1 is returned.nextSetBit in interface ChronicleBitSetfromIndex - the index to start checking frompublic int nextSetBit(int fromIndex,
int toIndex)
true that occurs on or after the specified starting index but before the toIndex.
If no such bit exists then -1 is returned.nextSetBit in interface ChronicleBitSetfromIndex - the index to start checking fromtoIndex - the index to stop checking (exclusive)public int nextClearBit(int fromIndex)
false that occurs on or after the specified starting index.nextClearBit in interface ChronicleBitSetfromIndex - the index to start checking frompublic int previousSetBit(int fromIndex)
true from the specified starting index moving backwards.
If the bit at the specified starting index is set to true, it will return the index itself.
If no such bit exists before the given index, or if -1 is the specified index, then -1 is returned.fromIndex - The starting index to begin the search. The search moves towards the index 0 from this point.true) before the specified starting index, or -1 if none exists.IndexOutOfBoundsException - if fromIndex is less than -1public int previousClearBit(int fromIndex)
false from the specified starting index moving backwards.
If the bit at the specified starting index is set to false, it will return the index itself.
If no such unset bit exists before the given index, or if -1 is the specified index, then -1 is returned.fromIndex - The starting index to begin the search. The search moves towards the index 0 from this point.false) before the specified starting index, or -1 if none exists.IndexOutOfBoundsException - if fromIndex is less than -1public boolean intersects(ChronicleBitSet set)
ChronicleBitSet has any common set bits with the specified ChronicleBitSet.
If any bits set to true in the provided set are also set to true in this set, then the method returns true.intersects in interface ChronicleBitSetset - The ChronicleBitSet to compare with the current instance.true if there's an intersection, otherwise false.public boolean intersects(LongValueBitSet set)
ChronicleBitSet intersects with the provided LongValueBitSet.
This method is an overloaded version of the intersects method, designed to work specifically with LongValueBitSet.set - The LongValueBitSet to compare with the current instance.true if there's an intersection, otherwise false.public int cardinality()
true in this ChronicleBitSet.cardinality in interface ChronicleBitSettrue.public void and(ChronicleBitSet set)
ChronicleBitSet and the specified ChronicleBitSet.
After this operation, a bit in this set will be set to true only if it was originally true and the corresponding bit in the specified set is true.and in interface ChronicleBitSetset - The ChronicleBitSet to perform the logical AND operation with.public void and(LongValueBitSet set)
ChronicleBitSet and the specified LongValueBitSet.
This is an overloaded version of the method that accepts ChronicleBitSet, designed to work with LongValueBitSet.
The logic of the operation is handled by the base method.set - The LongValueBitSet to perform the logical AND operation with.public void or(LongValueBitSet set)
ChronicleBitSet and the provided LongValueBitSet.
This overloaded version casts the provided set to its base type ChronicleBitSet before performing the operation.set - The LongValueBitSet to perform the logical OR operation with.public void or(ChronicleBitSet set)
ChronicleBitSet and the provided ChronicleBitSet.
Each bit in this set will be set to true if it was originally true or the corresponding bit in the provided set is true.or in interface ChronicleBitSetset - The ChronicleBitSet to perform the logical OR operation with.public 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 ChronicleBitSetset - The ChronicleBitSet to perform the logical XOR operation with.public void xor(LongValueBitSet set)
ChronicleBitSet and the specified LongValueBitSet.
This is an overloaded version of the method that accepts ChronicleBitSet, designed to work with LongValueBitSet.
The logic of the operation is handled by the base method.set - The LongValueBitSet to perform the logical XOR operation with.public void andNot(ChronicleBitSet set)
ChronicleBitSet where the corresponding bit is set in the specified ChronicleBitSet.
Effectively performs a logical AND NOT operation on this bit set with the given set.andNot in interface ChronicleBitSetset - The ChronicleBitSet to use for clearing matching bits.public void andNot(LongValueBitSet set)
ChronicleBitSet where the corresponding bit is set in the specified LongValueBitSet.
This is an overloaded version designed to work with LongValueBitSet.set - The LongValueBitSet to use for clearing matching bits.public int hashCode()
ChronicleBitSet. The hash code is calculated based on the bit values that are set.public int size()
ChronicleBitSet to represent bit values.
Essentially, this is the highest set bit plus one.size in interface ChronicleBitSetpublic boolean equals(Object obj)
ChronicleBitSet object against the specified object. The result is true if and only if:
null.
ChronicleBitSet.
ChronicleBitSet objects have the exact same set of bits set to true.
int index k, the bits of both ChronicleBitSet objects at index k should be identical.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 in the set state. The indices are returned in order, from lowest to
highest. The size of the stream is the number of bits in the set state, equal to 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.