|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectSciLib.Math.bitStream
public class bitStream
This class contains some methods to handle a string of bits.
| Constructor Summary | |
|---|---|
bitStream()
Allocates a new bitStream containing no data. |
|
bitStream(booleanVector bits)
Allocates a new bitStream containing a initialized booleanVector bits. |
|
bitStream(byte b)
Allocates a new bitString containing a bits representation of a byte b. |
|
bitStream(byte[] b)
Allocates a new bitString containing a bits representation of a byte array b. |
|
bitStream(char c,
boolean t)
Allocates a new bitString containing a bits representation of a character c. |
|
bitStream(int[] b)
Allocates a new bitStream containing a initialized pulse array. |
|
bitStream(int n,
boolean t)
Allocates a new bitStream containing a bits representation of an integer n. |
|
bitStream(java.lang.String b)
Allocates a new bitStream containing a initialized bit character String. |
|
| Method Summary | |
|---|---|
void |
add(boolean b)
Add one bit 'b' to this bitStream |
void |
add(char b)
Add one bit 'b' to this bitStream |
void |
add(int b)
Add one bit b to this bitStream |
bitStream |
and(bitStream b)
Apply and method between this bitStream and a bitStream b |
bitStream |
and(bitStream b,
int ind)
Apply and method between this bitStream and a bitStream b from the index i |
static boolean |
and(boolean i,
boolean j)
and operation |
static int |
and(int i,
int j)
and operation |
void |
append(bitStream b)
Append the bitStream with a bitStream b |
char |
bitAt(int i)
return the character of the bit i int the bitStream |
static char |
bitChar(boolean b)
convert a digital pulse to bit character |
static int |
bitrev(int n,
int q)
return a number that is made by bitreversal of the integer n using q-bits representation by q bits. |
static int |
bits2num(int q)
return the byggest integer number that can be repersented by q bits |
static boolean |
booleanPulse(char b)
convert a bit character to a digital pulse |
static boolean |
booleanPulse(int b)
convert an bit integer to a digital pulse |
boolean |
checkBit(int i,
int j,
boolean b)
Check a bit value in a sequence of bits from index i to index j |
static bitStream |
copy(bitStream bits)
Make a copy of a given bitStream |
void |
cutLeft(int n)
cut n bits of the bitStream from the left. |
void |
cutRight(int n)
cut n bits of the bitStream from the right. |
boolean |
elementAt(int i)
Return the bit i |
booleanVector |
getBits()
get the booleanVector of the bitStream |
static bitStream |
getBits(byte b,
int i,
int j)
get n bits in a byte from index the i to the index j |
java.lang.String |
getTitle()
get the title of the bitStream |
void |
leftShift(int n)
Left-Shift n bits |
bitStream |
not()
Apply or method between this bitStream and a bitStream b |
static int |
num2bits(int n)
compute the number of bits needed to represent an integer n. |
bitStream |
or(bitStream b)
Apply or method between this bitStream and a bitStream b |
bitStream |
or(bitStream b,
int ind)
Apply or method between this bitStream and a bitStream b from the index i |
static boolean |
or(boolean i,
boolean j)
or operation |
static int |
or(int i,
int j)
or operation |
void |
print()
write out the bitStream with System.out |
static int |
pulse(boolean b)
convert a digital pulse to an bit integer |
void |
rightShift(int n)
Right-Shift n bits |
void |
setBits(booleanVector bits)
Make a bitString object with an initialized string bits. |
void |
setBits(byte b)
Make a bitStream representation of a byte b. |
void |
setBits(byte[] b)
Make a bitStream representation of a byte array b. |
void |
setBits(char c)
Make a bitStream representation of a character c. |
void |
setBits(int n)
Make a bitStream representation of an integer n. |
void |
setElementAt(boolean b,
int i)
Set new value of the bitStream at index i |
void |
setTitle(java.lang.String name)
set Title to the bitStream |
int[] |
signal()
Make an array of integers that represents the bitStream |
int |
size()
return the size of the bitStream |
bitStream |
subBitStream(int from)
make a subBitStream from the index "from" to the end of this bitStream. |
bitStream |
subBitStream(int from,
int to)
Make a subBitStream from the index "from" to the index "to". |
java.lang.String |
toString()
Make a String from the bitStream |
void |
trim()
cut off the zeros leading of the bitString |
long |
value()
return the long value represented by bitStream. |
bitStream |
xor(bitStream b)
Apply xor method between this bitStream and a bitStream b |
bitStream |
xor(bitStream b,
int ind)
Apply xor method between this bitStream and a bitStream b from the index i |
static boolean |
xor(boolean i,
boolean j)
xor operation |
static int |
xor(int i,
int j)
xor operation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public bitStream()
public bitStream(int n,
boolean t)
n - An integert - A boolean, true for trim, i.e. cut off the zeros leading of the bitString
public bitStream(char c,
boolean t)
c - A charactert - A boolean, true for trim, i.e. cut off the zeros leading of the bitStringpublic bitStream(byte b)
b - A bytepublic bitStream(byte[] b)
b - A byte arraypublic bitStream(booleanVector bits)
bits - A booleanVectorpublic bitStream(int[] b)
b - An integer array of 0s and 1spublic bitStream(java.lang.String b)
b - A String of 0s and 1s| Method Detail |
|---|
public void trim()
public void setBits(int n)
n - An integerpublic void setBits(char c)
c - The characterpublic void setBits(byte b)
b - a bytepublic void setBits(byte[] b)
b - a byte arraypublic void setBits(booleanVector bits)
bits - A stringpublic static bitStream copy(bitStream bits)
bits - A bitStream
public void print()
public int size()
public void setTitle(java.lang.String name)
name - A Stringpublic java.lang.String getTitle()
public booleanVector getBits()
public char bitAt(int i)
public void append(bitStream b)
b - A bitStreampublic void add(boolean b)
b - A booleanpublic void add(char b)
b - A character, '1' or '0'public void add(int b)
b - An integer, 1 or 0
public bitStream subBitStream(int from,
int to)
from - start indexto - end index
public bitStream subBitStream(int from)
from - start index
public void cutLeft(int n)
n - The number of bitspublic void cutRight(int n)
n - The number of bitspublic static final int bits2num(int q)
q - The number of bits
public static final int num2bits(int n)
n - An integer number
public static final int bitrev(int n,
int q)
n - An integer numberq - The number of bits
public boolean elementAt(int i)
i - Index value
public void setElementAt(boolean b,
int i)
i - Index valueb - bit valuepublic static char bitChar(boolean b)
b - a pulse, on or off
public static int pulse(boolean b)
b - a pulse, on or off
public static boolean booleanPulse(int b)
b - An integer, 0 or 1
public static boolean booleanPulse(char b)
b - A character, '0' or '1'
public int[] signal()
public void leftShift(int n)
n - An integerpublic void rightShift(int n)
n - An integer
public boolean checkBit(int i,
int j,
boolean b)
i - from indexj - to in indexb - a pulse
public static boolean xor(boolean i,
boolean j)
i - a pulsej - a pulse
public static int xor(int i,
int j)
i - a bit valuej - a bit value
public static boolean and(boolean i,
boolean j)
i - pulsej - pulse
public static int and(int i,
int j)
i - a bit valuej - a bit value
public static boolean or(boolean i,
boolean j)
i - a pulsej - a pulse
public static int or(int i,
int j)
i - a bit valuej - a bit value
public long value()
public static bitStream getBits(byte b,
int i,
int j)
b - A bytei - the start indexj - the stop index
public bitStream and(bitStream b)
b - a bitStream
public bitStream or(bitStream b)
b - a bitStream
public bitStream xor(bitStream b)
b - a bitStream
public bitStream and(bitStream b,
int ind)
b - a bitStreamind - an integer value
public bitStream or(bitStream b,
int ind)
b - a bitStreamind - an integer value
public bitStream xor(bitStream b,
int ind)
b - a bitStreamind - an integer value
public bitStream not()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||