Package net.timewalker.ffmq4.utils
Class FastBitSet
- java.lang.Object
-
- net.timewalker.ffmq4.utils.FastBitSet
-
-
Constructor Summary
Constructors Constructor Description FastBitSet(int nbits)Creates a bit set of size nbits
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Sets all of the bits in this BitSet tofalse.voidclear(int bitIndex)Sets the bit specified by the index tofalse.voidensureCapacity(int requiredBits)Ensures that the BitSet can hold enough bits.booleanflip(int bitIndex)Sets the bit at the specified index to the complement of its current value.booleanget(int bitIndex)Returns the value of the bit with the specified index.voidset(int bitIndex)Sets the bit at the specified index totrue.intsize()Returns the number of bits of space actually in use by thisBitSetto represent bit values.
-
-
-
Method Detail
-
ensureCapacity
public void ensureCapacity(int requiredBits)
Ensures that the BitSet can hold enough bits.- Parameters:
requiredBits- the required number of bits.
-
flip
public boolean flip(int bitIndex)
Sets the bit at the specified index to the complement of its current value.- Parameters:
bitIndex- the index of the bit to flip- Returns:
- true if the bit was set to, false if it was unset
-
set
public void set(int bitIndex)
Sets the bit at the specified index totrue.- Parameters:
bitIndex- a bit index.
-
clear
public void clear(int bitIndex)
Sets the bit specified by the index tofalse.- Parameters:
bitIndex- the index of the bit to be cleared.
-
clear
public void clear()
Sets all of the bits in this BitSet tofalse.
-
get
public boolean get(int bitIndex)
Returns the value of the bit with the specified index. The value istrueif the bit with the indexbitIndexis currently set in thisBitSet; otherwise, the result isfalse.- Parameters:
bitIndex- the bit index.- Returns:
- the value of the bit with the specified index.
-
size
public int size()
Returns the number of bits of space actually in use by thisBitSetto represent bit values. The maximum element in the set is the size - 1st element.- Returns:
- the number of bits currently in this bit set.
-
-