public class PackedBitArray extends Object
| Constructor and Description | 
|---|
| PackedBitArray(int bitCount)Constructs a new bit array. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | clear()Clear all bits in the array. | 
| void | clear(int offset)Clears a bit at the given offset. | 
| void | clearBits(int offset,
         int length)Clears a run of bits at the given offset. | 
| int | getBitCount()Returns the number of bits maintained by this array. | 
| int | getByteCount()Returns the size of the byte buffer for this array. | 
| byte[] | getData()Returns the underlying byte buffer. | 
| void | set(int offset)Sets a bit at the given offset. | 
| void | setBits(int offset,
       int length)Sets a run of bits at the given offset to either 1. | 
| void | setBits(int offset,
       int length,
       int bit)Sets a run of bits at the given offset to either 1 or 0. | 
| static String | toBitString(byte data)Converts a byte to a "binary" String of 0s and 1s. | 
| static String | toBitString(byte[] data)Converts a series of bytes to a "binary" String of 0s and 1s. | 
| static String | toBitString(byte[] data,
           int start,
           int len)Converts a series of bytes to a "binary" String of 0s and 1s. | 
| String | toString() | 
public PackedBitArray(int bitCount)
bitCount - the number of bits to maintainpublic void set(int offset)
offset - the offsetpublic void clear(int offset)
offset - the offsetpublic void setBits(int offset,
           int length,
           int bit)
offset - the offsetlength - the number of bits to setbit - 1 to set the bit, 0 to clear itpublic void setBits(int offset,
           int length)
offset - the offsetlength - the number of bits to setpublic void clearBits(int offset,
             int length)
offset - the offsetlength - the number of bits to clearpublic void clear()
public int getBitCount()
public int getByteCount()
public byte[] getData()
Note: the actual buffer is returned. If it's manipulated the content of the bit array changes.
public static String toBitString(byte data)
data - the value to convertpublic static String toBitString(byte[] data)
data - the datapublic static String toBitString(byte[] data, int start, int len)
data - the datastart - the start offsetlen - the number of bytes to convertCopyright © 2002–2016 The Apache Software Foundation. All rights reserved.