Class BitSet64
java.lang.Object
Jcg.util.BitSet64
- All Implemented Interfaces:
BitSetInterface
An implementation of a bit-vector (using memory words on 64 bits)
- Author:
- Luca Castelli Aleardi (older version by Yonik)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intbits2words(int numBits) returns the number of 64 bit words it would take to hold numBitsintbitSize()Returns the size of the bitset (number of words)voidclear(int index) Clears a bit.booleanget(int index) Returns true or false for the specified bit index.intgetBit(int index) Returns 1 if the bit is set, 0 if not.long[]getBits()Expert: returns the long[] storing the bitsvoidset(int index) Sets the bit at the specified index.intsize()Returns the size of the bitset (number of words)boolean[]return an array of booleans corresponding to the bit-vectorvoidtoBoolean(boolean[] array) Convert the BitSet64 into an array of booleanstoString()
-
Field Details
-
numBits
private int numBits -
bits
private long[] bits -
wlen
private int wlen
-
-
Constructor Details
-
BitSet64
public BitSet64(int numBits) Constructs an OpenBitSet large enough to hold numBits.- Parameters:
numBits-
-
BitSet64
public BitSet64(boolean[] A) Constructs a BitSet64 from an input array of booleans- Parameters:
A- an array of booleans
-
-
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 of the bitset (number of words)- Specified by:
bitSizein interfaceBitSetInterface
-
getBits
public long[] getBits()Expert: returns the long[] storing the bits -
get
public boolean get(int index) Returns true or false for the specified bit index. The index should be less than the OpenBitSet size- 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- Specified by:
getBitin interfaceBitSetInterface
-
set
public void set(int index) Sets the bit at the specified index. The index should be less than the OpenBitSet size.- 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
-
bits2words
public static int bits2words(int numBits) returns the number of 64 bit words it would take to hold numBits -
toBoolean
public boolean[] toBoolean()return an array of booleans corresponding to the bit-vector -
toBoolean
public void toBoolean(boolean[] array) Convert the BitSet64 into an array of booleans- Parameters:
array- an input array of booleans
-
toString
-