Modifier and Type | Field and Description |
---|---|
protected byte[] |
array
The bit string data.
|
protected int |
length
The length of the bit string, in bits.
|
Constructor and Description |
---|
BitString(int length)
Construct a new
BitString of the specified length. |
BitString(int length,
boolean setInitially)
Construct a new
BitString of the specified length, with the
bits initialized to either the on or off position. |
Modifier and Type | Method and Description |
---|---|
void |
clear(int bit)
Clear the specified bit.
|
void |
clearAll()
Clear all of the bits.
|
boolean |
compareTo(BitString other)
Compare this
BitString to another. |
boolean |
equals(Object other)
Determine if this object is identical to another object.
|
int |
getLength()
Get the length of the
BitString . |
boolean |
isClear(int bit)
Test the specified bit.
|
boolean |
isSet(int bit)
Test the specified bit.
|
void |
set(int bit)
Set the specified bit.
|
void |
setAll()
Set all of the bits.
|
String |
toString()
Produce a string representation of the object.
|
protected byte[] array
protected int length
public BitString(int length)
BitString
of the specified length.length
- The length.public BitString(int length, boolean setInitially)
BitString
of the specified length, with the
bits initialized to either the on or off position.length
- The length.setInitially
- A flag indicating whether all bits should be initially
set or cleared.public int getLength()
BitString
.public void clearAll()
public void setAll()
public void set(int bit)
bit
- The index of the bit to set.IllegalArgumentException
- If the bit index is out of
range.public boolean isSet(int bit)
bit
- The index of the bit to test.true
if the bit is set, false
otherwise.IllegalArgumentException
- If the bit index is out of
range.public boolean isClear(int bit)
bit
- The index of the bit to test.true
if the bit is cleared, false
otherwise.IllegalArgumentException
- If the bit index is out of
range.public void clear(int bit)
bit
- The index of the bit to clear.IllegalArgumentException
- If the bit index is out of
range.public boolean compareTo(BitString other)
BitString
to another. The method
returns true
if the bits that are set in this
BitString
are also set in the other
BitString
. (This is not a test for equality; to test
if two BitStrings
have exactly the same bits set,
use equals()
.)other
- The BitString
to compare against.true
for a match, false
otherwise.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses