Constructor and Description |
---|
BitArray(int size) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all bits (sets to false).
|
void |
flip(int i)
Flips bit i.
|
boolean |
get(int i) |
int[] |
getBitArray() |
int |
getSize() |
boolean |
isRange(int start,
int end,
boolean value)
Efficient method to check if a range of bits is set, or not set.
|
private static int[] |
makeArray(int size) |
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.
|
String |
toString() |
public BitArray(int size)
public int getSize()
public boolean get(int i)
i
- bit to getpublic 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 setIllegalArgumentException
- if end is less than or equal to startpublic int[] getBitArray()
public void reverse()
private static int[] makeArray(int size)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses