public final class BitVector extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
private int[] |
bits |
private static int |
LOG_BITS_PER_UNIT |
private static int |
LOW_MASK |
private static int |
MASK |
private int |
nbits |
(package private) static long |
serialVersionUID
Support for serialization
|
Constructor and Description |
---|
BitVector(BitVector s)
Creates a copy of a Bit String
|
BitVector(int nbits)
Creates an empty string with the specified size.
|
Modifier and Type | Method and Description |
---|---|
void |
and(BitVector set)
Logically ANDs this bit set with the specified set of bits.
|
static BitVector |
and(BitVector b1,
BitVector b2) |
void |
clear(int bit)
Clears a bit.
|
void |
clearAll()
Clears all bits.
|
void |
copyBits(BitVector set)
Copies the values of the bits in the specified set into this set.
|
BitVector |
dup() |
boolean |
equals(Object obj)
Compares this object against the specified object.
|
boolean |
get(int bit)
Gets a bit.
|
int |
hashCode() |
boolean |
intersectionEmpty(BitVector other) |
boolean |
isZero() |
int |
length()
Calculates and returns the set's size in bits.
|
void |
not()
Logically NOT this bit string
|
static BitVector |
not(BitVector s) |
void |
or(BitVector set)
Logically ORs this bit set with the specified set of bits.
|
static BitVector |
or(BitVector b1,
BitVector b2) |
int |
populationCount() |
void |
set(int bit)
Sets a bit.
|
void |
setAll() |
private static int |
subscript(int bitIndex)
Convert bitIndex to a subscript into the bits[] array.
|
String |
toString() |
void |
xor(BitVector set)
Logically XORs this bit set with the specified set of bits.
|
static final long serialVersionUID
private static final int LOG_BITS_PER_UNIT
private static final int MASK
private static final int LOW_MASK
private final int[] bits
private final int nbits
public BitVector(int nbits)
nbits
- the size of the stringprivate static int subscript(int bitIndex)
bitIndex
- the bit indexpublic void setAll()
public void set(int bit)
bit
- the bit to be setpublic void clearAll()
public void clear(int bit)
bit
- the bit to be clearedpublic boolean get(int bit)
bit
- the bit to be gotten0
for false
public void not()
public void and(BitVector set)
set
- the bit set to be ANDed withpublic void or(BitVector set)
set
- the bit set to be ORed withpublic void xor(BitVector set)
set
- the bit set to be XORed withpublic boolean intersectionEmpty(BitVector other)
other
- the set to check intersection withpublic void copyBits(BitVector set)
set
- the bit set to copy the bits frompublic int populationCount()
public int length()
public boolean isZero()