Class BitSet32
java.lang.Object
Jcg.util.BitSet32
- All Implemented Interfaces:
BitSetInterface
An implementation of a bit-vector (using memory words on 32 bits)
- Author:
- Luca Castelli Aleardi (older version by Yonik)
-
Field Summary
FieldsModifier and TypeFieldDescriptionint[]intprivate intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbitSize()Returns the size in term of bitsvoidclear(int index) Clears a bit.booleanget(int index) intgetBit(int index) Returns 1 if the bit is set, 0 if not.voidset(int index) intsize()Returns the size of the bitset (number of words)byte[]Return an array of bytes storing the whole bit settoString()
-
Field Details
-
bits
public int[] bits -
numBits
public int numBits -
wordsLength
private int wordsLength -
wordSize
private int wordSize
-
-
Constructor Details
-
BitSet32
public BitSet32(int bitsSize) Constructs a BitSet large enough to hold numBits.- Parameters:
numBits- number of bits
-
BitSet32
public BitSet32(int[] bits, int bitsSize) Constructs a BitSet, from an array already initialized- Parameters:
bits- an array of integers storing the BitSetnumBits- number of bits
-
-
Method Details
-
size
public int size()Returns the size of the bitset (number of words)- Specified by:
sizein interfaceBitSetInterface
-
bitSize
public int bitSize()Returns the size in term of bits- Specified by:
bitSizein interfaceBitSetInterface
-
get
public boolean get(int index) - Specified by:
getin interfaceBitSetInterface
-
getBit
public int getBit(int index) Returns 1 if the bit is set, 0 if not. The index should be less than the OpenBitSet size LCA: a' controler- Specified by:
getBitin interfaceBitSetInterface
-
set
public void set(int index) - Specified by:
setin interfaceBitSetInterface
-
clear
public void clear(int index) Clears a bit. The index should be less than the OpenBitSet size.- Specified by:
clearin interfaceBitSetInterface
-
toByteArray
public byte[] toByteArray()Return an array of bytes storing the whole bit setRemark: the array of bytes is of size 4*W, where W is the number of words storing the bit set which is: size(bit set)/32
- Returns:
- an array of bytes, storing the values in the bit set
-
toString
-