public class Binary extends Variable
Modifier and Type | Field and Description |
---|---|
java.util.BitSet |
bits_
Stores the bits constituting the binary string.
|
protected int |
numberOfBits_
Store the length of the binary string
|
Constructor and Description |
---|
Binary()
Default constructor.
|
Binary(Binary variable)
Copy constructor.
|
Binary(int numberOfBits)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
decode()
This method is intended to be used in subclass of
Binary ,
for examples the classes, BinaryReal and BinaryInt |
Variable |
deepCopy()
Creates an exact copy of a Binary object
|
boolean |
getIth(int bit)
Returns the value of the ith bit.
|
int |
getNumberOfBits()
Returns the length of the binary string.
|
int |
hammingDistance(Binary other)
Obtain the hamming distance between two binary strings
|
void |
setIth(int bit,
boolean value)
Sets the value of the ith bit.
|
java.lang.String |
toString() |
getLowerBound, getUpperBound, getValue, getVariableType, setLowerBound, setUpperBound, setValue
public java.util.BitSet bits_
protected int numberOfBits_
public Binary()
public Binary(int numberOfBits)
numberOfBits
- Length of the bit stringpublic Binary(Binary variable)
variable
- The Binary variable to copy.public void decode()
Binary
,
for examples the classes, BinaryReal
and BinaryInt.
In this classes, the method allows to decode the
value enconded in the binary string. As generic variables do not encode any
value, this method do noting
public Variable deepCopy()
public int getNumberOfBits()
public boolean getIth(int bit)
bit
- The bit to retrievepublic void setIth(int bit, boolean value)
bit
- The bit to setpublic int hammingDistance(Binary other)
other
- The binary string to comparepublic java.lang.String toString()
toString
in class java.lang.Object