|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.util.BitUtils
public final class BitUtils
Utilities for dealing with byte[]s as bit vectors.
| Method Summary | |
|---|---|
static boolean |
get(byte[] barr,
int n)
Get the nth bit in the given byte[]. |
static byte[] |
newBitVector(int bitCount)
Construct a new byte[] initially capable of holding
bitCount bits. |
static void |
set(byte[] barr,
int n,
boolean value)
Set the nth bit in the given byte[] to
the given value. |
static byte[] |
stretchSet(byte[] barr,
int n,
boolean value)
Set the nth bit in the given byte[] to
the given value, making a new larger array to hold the bit if
necessary. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static byte[] newBitVector(int bitCount)
byte[] initially capable of holding
bitCount bits.
bitCount - the number of bits to hold
byte[]
public static void set(byte[] barr,
int n,
boolean value)
nth bit in the given byte[] to
the given value.
barr - non-null; the array to set inn - which bit to setvalue - the value for the bit
NullPointerException - thrown if barr == null
IndexOutOfBoundsException - thrown if n is
out of range
public static byte[] stretchSet(byte[] barr,
int n,
boolean value)
nth bit in the given byte[] to
the given value, making a new larger array to hold the bit if
necessary. (A new array is always allocated if barr is
passed as null.)
barr - null-ok; the array to set inn - which bit to setvalue - the value for the bit
barr if barr is
null or too small)
IndexOutOfBoundsException - thrown if n < 0
public static boolean get(byte[] barr,
int n)
nth bit in the given byte[]. This
is lenient and will simply return false if n
is out of range or barr is null.
barr - null-ok; the array to queryn - which bit to get
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||