|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--lava.util.BitTwiddler
Bit-twiddling operations.
BitTwiddler is a collection of static methods that perform bit-twiddling operations.
| Constructor Summary | |
BitTwiddler()
|
|
| Method Summary | |
static java.lang.String |
bitString(int value,
int blocksize)
Represents an int in binary notation as a string of zeros and ones. |
static int |
countSetBits(byte b)
Counts set bits. |
static int |
countSetBits(int i)
Counts set bits. |
static int |
countSetBits(long l)
Counts set bits. |
static int |
countSetBits(short s)
Counts set bits. |
static int |
mostSignificant(int integer,
boolean value)
Searches for a bit value in an int. |
static int |
reverseBits(int i)
Reverses order of bits in ing. |
static long |
reverseBits(long l)
Reverses order of bits in long. |
static int |
reverseEndian(int i)
Reverses endianness of int. |
static long |
reverseEndian(long l)
Reverses endianness of long. |
static short |
reverseEndian(short s)
Reverses endianness of short. |
static byte[] |
toBytesBe(int i,
byte[] dest,
int offset)
Breaks int into big endian bytes. |
static byte[] |
toBytesBe(long l,
byte[] dest,
int offset)
Breaks long into big endian bytes. |
static byte[] |
toBytesBe(short s,
byte[] dest,
int offset)
Breaks short into big endian bytes. |
static byte[] |
toBytesLe(int i,
byte[] dest,
int offset)
Breaks int into little endian bytes. |
static byte[] |
toBytesLe(long l,
byte[] dest,
int offset)
Breaks long into little endian bytes. |
static byte[] |
toBytesLe(short s,
byte[] dest,
int offset)
Breaks short into little endian bytes. |
static int |
toIntBe(byte[] b)
Shorthand for toIntBe (b, 0). |
static int |
toIntBe(byte[] b,
int offset)
Converts big endian bytes into int. |
static int |
toIntLe(byte[] b)
Shorthand for toIntLe (b, 0). |
static int |
toIntLe(byte[] b,
int offset)
Converts little endian bytes into int. |
static long |
toLongBe(byte[] b)
Shorthand for toLongBe (b, 0). |
static long |
toLongBe(byte[] b,
int offset)
Converts big endian bytes into long. |
static long |
toLongLe(byte[] b)
Shorthand for toLongLe (b, 0). |
static long |
toLongLe(byte[] b,
int offset)
Converts little endian bytes into long. |
static short |
toShortBe(byte[] b)
Shorthand for toShortBe (b, 0). |
static short |
toShortBe(byte[] b,
int offset)
Converts big endian bytes into short. |
static short |
toShortLe(byte[] b)
Shorthand for toShortLe (b, 0). |
static short |
toShortLe(byte[] b,
int offset)
Converts little endian bytes into short. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BitTwiddler()
| Method Detail |
public static final long toLongBe(byte[] b,
int offset)
Details: This method converts big endian ordered bytes into a long. offset is the array index of the first byte.
b - the byte arraythe - array offset (default value: 0)public static final long toLongBe(byte[] b)
toLongBe(byte[], int)
public static final long toLongLe(byte[] b,
int offset)
Details: This method converts little endian ordered bytes into a long. offset is the array index of the first byte.
b - the byte arraythe - array offset (default value: 0)public static final long toLongLe(byte[] b)
toLongLe(byte[], int)
public static final int toIntBe(byte[] b,
int offset)
Details: This method converts big endian ordered bytes into an int. offset is the array index of the first byte.
b - the byte arraythe - array offset (default value: 0)public static final int toIntBe(byte[] b)
toIntBe(byte[], int)
public static final int toIntLe(byte[] b,
int offset)
Details: This method converts little endian ordered bytes into an int. offset is the array index of the first byte.
b - the byte arraythe - array offset (default value: 0)public static final int toIntLe(byte[] b)
toIntLe(byte[], int)
public static final short toShortBe(byte[] b,
int offset)
Details: This method converts big endian ordered bytes into a short. offset is the array index of the first byte.
b - the byte arraythe - array offset (default value: 0)public static final short toShortBe(byte[] b)
toShortBe(byte[], int)
public static final short toShortLe(byte[] b,
int offset)
Details: This method converts little endian ordered bytes into a short. offset is the array index of the first byte.
b - the byte arraythe - array offset (default value: 0)public static final short toShortLe(byte[] b)
toShortLe(byte[], int)
public static final byte[] toBytesBe(long l,
byte[] dest,
int offset)
Details: This method breaks a long into 8 bytes and stores them in the given array, at the given index, using big endian byte ordering.
l - the longdest - the destination arrayoffset - the array index
public static final byte[] toBytesLe(long l,
byte[] dest,
int offset)
Details: This method breaks a long into 8 bytes and stores them in the given array, at the given index, using little endian byte ordering.
l - the longdest - the destination arrayoffset - the array index
public static final byte[] toBytesBe(int i,
byte[] dest,
int offset)
Details: This method breaks an int into 4 bytes and stores them in the given array, at the given index, using big endian byte ordering.
i - the intdest - the destination arrayoffset - the array index
public static final byte[] toBytesLe(int i,
byte[] dest,
int offset)
Details: This method breaks an int into 4 bytes and stores them in the given array, at the given index, using little endian byte ordering.
i - the intdest - the destination arrayoffset - the array index
public static final byte[] toBytesBe(short s,
byte[] dest,
int offset)
Details: This method breaks a short into 2 bytes and stores them in the given array, at the given index, using big endian byte ordering.
s - the shortdest - the destination arrayoffset - the array index
public static final byte[] toBytesLe(short s,
byte[] dest,
int offset)
Details: This method breaks a short into 2 bytes and stores them in the given array, at the given index, using little endian byte ordering.
s - the shortdest - the destination arrayoffset - the array indexpublic static final long reverseEndian(long l)
l - the longpublic static final int reverseEndian(int i)
i - the intpublic static final short reverseEndian(short s)
s - the shortpublic static final long reverseBits(long l)
l - the longpublic static final int reverseBits(int i)
i - the int
public static java.lang.String bitString(int value,
int blocksize)
value - the value to representblocksize - the number digits per blockvalue
public static final int mostSignificant(int integer,
boolean value)
int. Returns the position of the most significant bit matching the given value, or -1 if the bit value does not occur at all in integer.integer - the intpublic static final int countSetBits(long l)
Details: This method returns the number of bits in l that are 1.
l - a longpublic static final int countSetBits(int i)
Details: This method returns the number of bits in i that are 1.
i - an intpublic static final int countSetBits(short s)
Details: This method returns the number of bits in s that are 1.
s - a shortpublic static final int countSetBits(byte b)
Details: This method returns the number of bits in b that are 1.
b - a byte
|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||