public class BitSetMath extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(BitSet from,
BitSet to)
Makes the bit set
to equal to from. |
static void |
extractBitRange(BitSet chi,
int from,
int to,
BitSet r)
Unfortunately BitSet.get cannot reuse an existing instance so we have this
method for exactly that purpose.
|
static void |
grayCode(BitSet i)
Computes
i's gray code in-place. |
static void |
grayCodeInverse(BitSet i)
Given the gray code of a number, it computes that number in-place.
|
static int |
increment(BitSet i)
Increments the given bit set in-place, looking at it as a little-endian
value with no bit sign (always non-negative).
|
static long |
littleEndianBitSetToNonNegativeLong(BitSet bs)
Produces a
long from a little endian bit set. |
static void |
nonNegativeLongToLittleEndianBitSet(long value,
BitSet bs)
Computes the little endian representation of a non-negative long.
|
static void |
rotate(BitSet bs,
int n,
int count)
Rotates the lowest
n bits by count positions in-place. |
public static int increment(BitSet i)
public static void rotate(BitSet bs, int n, int count)
n bits by count positions in-place. The
bits of index higher than or equal to n are not affected.bs - input-outputn - the number of lowest bits to rotatecount - right rotation if positive; left rotation if negative;
no rotation at all if zero.public static void extractBitRange(BitSet chi, int from, int to, BitSet r)
chi - original bit set to extract bits fromfrom - inclusive start of range to extractto - exclusive end of range to extractr - outputpublic static void grayCode(BitSet i)
i's gray code in-place.i - input-outputpublic static void grayCodeInverse(BitSet i)
i - input-outputpublic static void copy(BitSet from, BitSet to)
to equal to from.from - sourceto - destinationpublic static long littleEndianBitSetToNonNegativeLong(BitSet bs)
long from a little endian bit set.bs - little endian base 2 number representationbs, but represented as longpublic static void nonNegativeLongToLittleEndianBitSet(long value,
BitSet bs)
littleEndianBitSetToNonNegativeLong(java.util.BitSet).value - inputbs - outputCopyright © 2014. All Rights Reserved.