|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.zxing.common.BitArray
public final class BitArray
A simple, fast array of bits, represented compactly by an array of ints internally.
Field Summary | |
---|---|
int[] |
bits
|
int |
size
|
Constructor Summary | |
---|---|
BitArray()
|
|
BitArray(int size)
|
Method Summary | |
---|---|
void |
appendBit(boolean bit)
|
void |
appendBitArray(BitArray other)
|
void |
appendBits(int value,
int numBits)
Appends the least-significant bits, from value, in order from most-significant to least-significant. |
void |
clear()
Clears all bits (sets to false). |
void |
flip(int i)
Flips bit i. |
boolean |
get(int i)
|
int[] |
getBitArray()
|
int |
getSize()
|
int |
getSizeInBytes()
|
boolean |
isRange(int start,
int end,
boolean value)
Efficient method to check if a range of bits is set, or not set. |
void |
reverse()
Reverses all bits in the array. |
void |
set(int i)
Sets bit i. |
void |
setBulk(int i,
int newBits)
Sets a block of 32 bits, starting at bit i. |
void |
toBytes(int bitOffset,
byte[] array,
int offset,
int numBytes)
|
String |
toString()
|
void |
xor(BitArray other)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public int[] bits
public int size
Constructor Detail |
---|
public BitArray()
public BitArray(int size)
Method Detail |
---|
public int getSize()
public int getSizeInBytes()
public boolean get(int i)
i
- bit to get
public void set(int i)
i
- bit to setpublic void flip(int i)
i
- bit to setpublic void setBulk(int i, int newBits)
i
- first bit to setnewBits
- the new value of the next 32 bits. Note again that the least-significant bit
corresponds to bit i, the next-least-significant to i+1, and so on.public void clear()
public boolean isRange(int start, int end, boolean value)
start
- start of range, inclusive.end
- end of range, exclusivevalue
- if true, checks that bits in range are set, otherwise checks that they are not set
IllegalArgumentException
- if end is less than or equal to startpublic void appendBit(boolean bit)
public void appendBits(int value, int numBits)
public void appendBitArray(BitArray other)
public void xor(BitArray other)
public void toBytes(int bitOffset, byte[] array, int offset, int numBytes)
bitOffset
- first bit to start writingarray
- array to write into. Bytes are written most-significant byte first. This is the opposite
of the internal representation, which is exposed by getBitArray()
offset
- position in array to start writingnumBytes
- how many bytes to writepublic int[] getBitArray()
public void reverse()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |