Package org.apache.activemq.util
Class BitArray
- java.lang.Object
-
- org.apache.activemq.util.BitArray
-
- All Implemented Interfaces:
Serializable
public class BitArray extends Object implements Serializable
Simple BitArray to enable setting multiple boolean values efficently Used instead of BitSet because BitSet does not allow for efficent serialization. Will store up to 64 boolean values- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BitArray()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
get(int index)
long
getBits()
int
length()
void
readFromStream(DataInput dataIn)
read the bits from an input streamvoid
reset()
reset all the bit values to falsevoid
reset(long bits)
reset all the bits to the value suppliedboolean
set(int index, boolean flag)
set the boolean value at the indexvoid
writeToStream(DataOutput dataOut)
write the bits to an output stream
-
-
-
Method Detail
-
length
public int length()
- Returns:
- the length of bits set
-
getBits
public long getBits()
- Returns:
- the long containing the bits
-
set
public boolean set(int index, boolean flag)
set the boolean value at the index- Parameters:
index
-flag
-- Returns:
- the old value held at this index
-
get
public boolean get(int index)
- Parameters:
index
-- Returns:
- the boolean value at this index
-
reset
public void reset()
reset all the bit values to false
-
reset
public void reset(long bits)
reset all the bits to the value supplied- Parameters:
bits
-
-
writeToStream
public void writeToStream(DataOutput dataOut) throws IOException
write the bits to an output stream- Parameters:
dataOut
-- Throws:
IOException
-
readFromStream
public void readFromStream(DataInput dataIn) throws IOException
read the bits from an input stream- Parameters:
dataIn
-- Throws:
IOException
-
-