|
eaLib API Docs Last Modified : January 7 2002 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--mss.ea.core.BitVector
Replacement for Sun's unflexible BitSet. This class provides an internal boundchecking. If an invalid index is given the appropriate method does simply nothing. For convinience reasons no exception is thrown in such a case.
Field Summary | |
protected static byte[] |
oneMask
Byte array, for masking single bits with one. |
protected byte[] |
set
All bits are kept in this byte array. |
protected int |
setSize
Size of byte array. |
protected static byte[] |
zeroMask
Byte array, for masking single bits with zero. |
Constructor Summary | |
BitVector()
Constructor with initial size of 8 bits. |
|
BitVector(byte ini)
Constructs a new bitvector from a byte. |
|
BitVector(byte[] ba)
Constructor with byte array. |
|
BitVector(byte[] ba,
boolean reverse)
Constructor with byte array. |
|
BitVector(int size)
Constructor with size of BitVector. |
|
BitVector(int ini,
boolean intFlag)
Constructs a new bitvector from an int number. |
|
BitVector(long ini)
Constructs a new bitvector from a long number. |
|
BitVector(short ini)
Constructs a new bitvector from a short number. |
|
BitVector(java.lang.String bitstring)
Constructor with string. |
Method Summary | |
BitVector |
and(BitVector bv)
Performs an AND operation. |
int |
byteSize()
This returns the number of the the bytes used for holding the bit vector. |
void |
clear(int index)
Clears a single bits. |
java.lang.Object |
clone()
Clones the bit vector. |
boolean |
get(int index)
Gets a single bit. |
BitVector |
getBitVector(int index,
int length)
Gets a new bitvector with bits starting at a particular position. |
byte |
getByte(int byteIndex)
Gets a byte from the bitvector. |
byte |
getByte(int bitIndex,
int length)
Gets a byte from the bitvector starting at a particular position. |
int |
getInteger(int index)
Gets a single bit and returns the value as an integer. |
protected boolean |
internalGet(int index)
Gets a single bit. |
protected void |
internalSet(int index)
Sets a single bit. |
protected void |
internalSet(int index,
boolean value)
Sets a single bit. |
protected void |
internalUnset(int index)
Clears a single bit. |
int |
intValue()
Returns the lowest 4 bytes from the bit vector as an integer number. |
long |
longValue()
Returns the lowest 8 bytes of the bit vector as a long number. |
void |
not()
Inverts the bitvector. |
BitVector |
or(BitVector bv)
Performs an OR operation. |
void |
randomize()
Fills the bit vector with random bits. |
void |
rclear(int index)
Clears a single bit and resizes the bit vector, if necessary. |
void |
rset(int index)
Sets a single bit and resizes the bit vector, if necessary. |
void |
runset(int index)
Clears a single bit and resizes the bit vector, if necessary. |
void |
set(int index)
Sets a single bit. |
void |
set(int index,
boolean value)
Sets a single bit. |
void |
set(int index,
int value)
Sets a single bit. |
void |
shiftLeft()
Shifts the bitvector to the left. |
void |
shiftLeft(int times)
Shifts the bitvector n times to the left. |
void |
shiftRight()
Shifts the bitvector to the right. |
void |
shiftRight(int times)
Shifts the bitvector n times to the right. |
int |
size()
Gets the size of the bitvector. |
java.lang.String |
toBinaryString()
Returns a string representation of the bitvector. |
java.lang.String |
toBitSetString()
Returns a string representation, which equals the one Sun's BitSet returns. |
void |
toggle(int index)
Inverts a bit. |
static boolean |
toggleBit(boolean bit)
Inverts a boolean value. |
java.lang.String |
toHexString()
Returns a hexadecimal string representation of the bitvector. |
java.lang.String |
toHexString(boolean withPrefix)
Returns a hexadecimal string representation of the bitvector. |
java.lang.String |
toString()
Returns a string representation of the bitvector. |
void |
unset(int index)
Clears a single bits. |
BitVector |
xor(BitVector bv)
Performs an XOR operation. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected byte[] set
protected int setSize
protected static final byte[] zeroMask
protected static final byte[] oneMask
Constructor Detail |
public BitVector()
public BitVector(int size)
size
- size of bit vectorpublic BitVector(byte ini)
ini
- byte to construct bitvector frompublic BitVector(short ini)
ini
- short number to construct bitvector frompublic BitVector(int ini, boolean intFlag)
ini
- int number to construct bitvector fromintFlag
- this is used to differentiate this constructor from
public BitVector(long ini)
ini
- long number to construct bitvector frompublic BitVector(byte[] ba)
ba
- initial byte arraypublic BitVector(byte[] ba, boolean reverse)
ba
- initial byte arrayreverse
- if true, reverses the byte vectorpublic BitVector(java.lang.String bitstring)
bitstring
- string that this bit vector is constructed fromMethod Detail |
public boolean get(int index)
index
- position of bit in bit vectorpublic int getInteger(int index)
index
- position of the bit in bit vectorpublic byte getByte(int byteIndex)
byteIndex
- position of byte in byte arraypublic byte getByte(int bitIndex, int length)
bitIndex
- position of the starting bit in the bitvectorlength
- number of bits to get (values > 8 will be ignored)public BitVector getBitVector(int index, int length)
index
- position of the starting bit in the current bitvectorlength
- number of bits to getprotected boolean internalGet(int index)
get(int)
, but works without boundchecking.index
- position of the bit in bit vectorprotected void internalSet(int index)
set(int)
, but works without boundchecking.index
- position of the bit in bit vectorprotected void internalSet(int index, boolean value)
set(int, boolean)
, but works without boundchecking.index
- position of the bit in bit vectorvalue
- value of the bitprotected void internalUnset(int index)
unset(int)
, but works without boundchecking.index
- position of the bit in bit vectorpublic void set(int index)
index
- position of the bit in bit vectorpublic void set(int index, boolean value)
index
- position of the bit in bit vectorvalue
- value of the bitpublic void set(int index, int value)
index
- position of the bit in bit vectorvalue
- value of the bitpublic void rset(int index)
index
- position of the bit in bit vectorpublic void unset(int index)
index
- position of the bit in bit vectorpublic void clear(int index)
index
- position of the bit in bit vectorpublic void runset(int index)
index
- position of the bit in bit vectorpublic void rclear(int index)
index
- index of the bit to be clearedpublic BitVector and(BitVector bv)
bv
- second bitvector to use for for AND operationpublic void not()
public BitVector or(BitVector bv)
bv
- second bitvector to use for for OR operationpublic BitVector xor(BitVector bv)
bv
- second bitvector to use for for XOR operationpublic void shiftLeft()
public void shiftLeft(int times)
times
- number of shift operationspublic void shiftRight()
public void shiftRight(int times)
times
- number of shift operationspublic int size()
public int byteSize()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toBinaryString()
toString()
, but whitespaces ar missing.public java.lang.String toHexString()
public java.lang.String toHexString(boolean withPrefix)
withPrefix
- if true, the prefix "0x" is usedpublic java.lang.String toBitSetString()
public int intValue()
public long longValue()
public void toggle(int index)
index
- position of the bit in bit vectorpublic static boolean toggleBit(boolean bit)
bit
- value to be invertedpublic void randomize()
public java.lang.Object clone()
clone
in class java.lang.Object
|
eaLib API Docs Last Modified : January 7 2002 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |