public class ThreadSafeBitSet
extends java.lang.Object
BitSet
.Instead of a long array to hold the bits, this implementation uses an AtomicLongArray, then does the appropriate compare-and-swap operations when setting the bits.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LOG2_SEGMENT_SIZE_IN_BITS |
Constructor and Description |
---|
ThreadSafeBitSet() |
ThreadSafeBitSet(int log2SegmentSizeInBits) |
ThreadSafeBitSet(int log2SegmentSizeInBits,
int numBitsToPreallocate) |
Modifier and Type | Method and Description |
---|---|
ThreadSafeBitSet |
andNot(ThreadSafeBitSet other)
Return a new bit set which contains all bits which are contained in this bit set, and which are NOT contained in the
other bit set. |
int |
cardinality() |
void |
clear(int position) |
void |
clearAll()
Clear all bits to 0.
|
int |
currentCapacity() |
boolean |
equals(java.lang.Object obj) |
boolean |
get(int position) |
int |
hashCode() |
long |
maxSetBit() |
int |
nextSetBit(int fromIndex) |
static ThreadSafeBitSet |
orAll(ThreadSafeBitSet... bitSets)
Return a new bit set which contains all bits which are contained in *any* of the specified bit sets.
|
void |
serializeBitsTo(java.io.DataOutputStream os) |
void |
set(int position) |
java.util.BitSet |
toBitSet() |
java.lang.String |
toString() |
public static final int DEFAULT_LOG2_SEGMENT_SIZE_IN_BITS
public ThreadSafeBitSet()
public ThreadSafeBitSet(int log2SegmentSizeInBits)
public ThreadSafeBitSet(int log2SegmentSizeInBits, int numBitsToPreallocate)
public void set(int position)
public void clear(int position)
public boolean get(int position)
public long maxSetBit()
public int nextSetBit(int fromIndex)
public int cardinality()
public int currentCapacity()
public void clearAll()
public ThreadSafeBitSet andNot(ThreadSafeBitSet other)
other
bit set.In other words, return a new bit set, which is a bitwise and with the bitwise not of the other bit set.
other
- the other bit setpublic static ThreadSafeBitSet orAll(ThreadSafeBitSet... bitSets)
bitSets
- the other bit setspublic void serializeBitsTo(java.io.DataOutputStream os) throws java.io.IOException
java.io.IOException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.util.BitSet toBitSet()
public java.lang.String toString()
toString
in class java.lang.Object