com.google.zxing.common
Class BitArray

java.lang.Object
  extended by com.google.zxing.common.BitArray

public final class BitArray
extends Object

A simple, fast array of bits, represented compactly by an array of ints internally.

Since:
BlackBerry API 6.0.0

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()
          Returns a string representation of the object.
 void xor(BitArray other)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 



Field Detail

bits

public int[] bits
Since:
BlackBerry API 6.0.0

size

public int size
Since:
BlackBerry API 6.0.0


Constructor Detail

BitArray

public BitArray()
Since:
BlackBerry API 7.0.0

BitArray

public BitArray(int size)
Since:
BlackBerry API 6.0.0


Method Detail

getSize

public int getSize()
Since:
BlackBerry API 6.0.0

getSizeInBytes

public int getSizeInBytes()
Since:
BlackBerry API 7.0.0

get

public boolean get(int i)
Parameters:
i - bit to get
Returns:
true iff bit i is set
Since:
BlackBerry API 6.0.0

set

public void set(int i)
Sets bit i.

Parameters:
i - bit to set
Since:
BlackBerry API 6.0.0

flip

public void flip(int i)
Flips bit i.

Parameters:
i - bit to set
Since:
BlackBerry API 6.0.0

setBulk

public void setBulk(int i,
                    int newBits)
Sets a block of 32 bits, starting at bit i.

Parameters:
i - first bit to set
newBits - 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.
Since:
BlackBerry API 6.0.0

clear

public void clear()
Clears all bits (sets to false).

Since:
BlackBerry API 6.0.0

isRange

public boolean isRange(int start,
                       int end,
                       boolean value)
Efficient method to check if a range of bits is set, or not set.

Parameters:
start - start of range, inclusive.
end - end of range, exclusive
value - if true, checks that bits in range are set, otherwise checks that they are not set
Returns:
true iff all bits are set or not set in range, according to value argument
Throws:
IllegalArgumentException - if end is less than or equal to start
Since:
BlackBerry API 6.0.0

appendBit

public void appendBit(boolean bit)
Since:
BlackBerry API 7.0.0

appendBits

public void appendBits(int value,
                       int numBits)
Appends the least-significant bits, from value, in order from most-significant to least-significant. For example, appending 6 bits from 0x000001E will append the bits 0, 1, 1, 1, 1, 0 in that order.

Since:
BlackBerry API 7.0.0

appendBitArray

public void appendBitArray(BitArray other)
Since:
BlackBerry API 7.0.0

xor

public void xor(BitArray other)
Since:
BlackBerry API 7.0.0

toBytes

public void toBytes(int bitOffset,
                    byte[] array,
                    int offset,
                    int numBytes)
Parameters:
bitOffset - first bit to start writing
array - array to write into. Bytes are written most-significant byte first. This is the opposite of the internal representation, which is exposed by BitArray.getBitArray()
offset - position in array to start writing
numBytes - how many bytes to write
Since:
BlackBerry API 7.0.0

getBitArray

public int[] getBitArray()
Returns:
underlying array of ints. The first element holds the first 32 bits, and the least significant bit is bit 0.
Since:
BlackBerry API 6.0.0

reverse

public void reverse()
Reverses all bits in the array.

Since:
BlackBerry API 6.0.0

toString

public String toString()
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.
Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal