Constructor and Description |
---|
Bits()
Default constructor to be used by the read() method
|
Bits(Bits other)
Copy constructor.
|
Bits(Bits other,
int length) |
Bits(int length)
Constructs a Bits vector of a given length
|
Bits(int length,
boolean value)
Constructs a Bits vector of a given length filled with
the given value.
|
Modifier and Type | Method and Description |
---|---|
void |
and(Bits other)
Bitwise AND operator
|
void |
clear()
Clears the vector
|
void |
clear(int p)
Clears a bit
|
int |
count()
Counts the number of set elements
|
boolean |
equals(Object o) |
boolean |
get(int p)
Gets the value of a given bit index
|
int |
getBits(int e,
int b) |
int[] |
getOnes()
Retrieves the indexes of the set elements in the vector
|
void |
or(Bits other)
Bitwise OR operator
|
void |
readFields(DataInput in) |
void |
set(int p)
Sets a bit to 1
|
void |
set(int p,
boolean on)
Sets the value of a bit.
|
int |
size()
Gets the total number of bits (i.e., the length of the vector)
|
String |
toString() |
void |
write(DataOutput out) |
void |
xor(Bits other)
Bitwise XOR operator
|
public Bits()
public Bits(Bits other)
other
- Bits object to be copiedpublic Bits(Bits other, int length)
public Bits(int length)
length
- Length of the vector.public Bits(int length, boolean value)
length
- Length of the vectorvalue
- Default value for bitspublic void and(Bits other)
other
- A second Bits vector to ANDpublic void clear()
public void clear(int p)
p
- Index of the bitpublic int count()
public boolean get(int p)
p
- Index of the bitpublic int getBits(int e, int b)
public int[] getOnes()
public void or(Bits other)
other
- A second Bits vector to ORpublic void readFields(DataInput in) throws IOException
readFields
in interface Writable
IOException
public void set(int p)
p
- Index of the bitpublic void set(int p, boolean on)
p
- Index of the biton
- Value of the bitpublic int size()
public void write(DataOutput out) throws IOException
write
in interface Writable
IOException
public void xor(Bits other)
other
- A second Bits vector to XOR