The list of methods to do BitSet are organized into topic(s).
int[]
asArrayWith0s(int max, BitSet bits) gets an array in which the i-th component has value i, if and only if i is contained in bits
final int[] array = new int[max + 1];
for (Integer t : members(bits))
array[t] = t;
return array;
BitSet
binaryStringToBitSet(String stringRepresentation) Convert the string representation to a bit set
BitSet bitSet = new BitSet(stringRepresentation.length());
for (int i = 0; i < stringRepresentation.length(); i++) {
if (stringRepresentation.charAt(i) == '1') {
bitSet.set(i);
} else if (stringRepresentation.charAt(i) != '0') {
throw new IllegalArgumentException("bad format: " + stringRepresentation);
return bitSet;
BitSet
binaryToGray(BitSet binary) binary To Gray
if (binary.equals(ZERO)) {
return (BitSet) ZERO.clone();
} else {
BitSet gray = (BitSet) binary.clone();
gray.xor(binary.get(1, binary.length()));
return gray;
BitSet
BitString2BitSet(String string) Converts the given {0,1}-String to a BitSet .
char[] chStr = string.toCharArray();
BitSet bitset = new BitSet(chStr.length);
for (int i = 0; i < chStr.length; i++) {
if (chStr[chStr.length - i - 1] == '1') {
bitset.set(i);
return bitset;
...
BitSet
byte2BitSet(BitSet bmap, byte[] b, int bitOffset) Converts a binary representation of a Bitmap field into a Java BitSet
int len = b.length << 3;
for (int i = 0; i < len; i++)
if (((b[i >> 3]) & (0x80 >> (i % 8))) > 0)
bmap.set(bitOffset + i + 1);
return bmap;
BitSet
byteArray2BitSet(byte[] bytes) Returns a bitset containing the values in bytes.
BitSet bits = new BitSet();
for (int i = 0; i < bytes.length * 8; i++) {
if ((bytes[bytes.length - i / 8 - 1] & (1 << (i % 8))) > 0) {
bits.set(i);
return bits;