List of utility methods to do BitSet
BitSet | not(BitSet bitSets) not bitSets.flip(0, bitSets.size());
return bitSets;
|
BitSet | or(BitSet bs1, BitSet bs2) Logical OR two bit sets without modifying the source. BitSet bsr = (BitSet) bs1.clone();
bsr.or(bs2);
return bsr;
|
Object | pack(BitSet bitSet) pack List<Long> values = new ArrayList<Long>(); long value = 0L; int j = 0; for (int i = 0; i < bitSet.size();) { if (bitSet.get(i)) { value |= (1L << j); i += 1; ... |
BitSet | padToByteBoundary(BitSet actualParameter, int sizeInBits, int byteBoundLength, boolean preserveFirstAsSign) pad To Byte Boundary BitSet paddedSet = new BitSet(byteBoundLength); int numPaddingBits = byteBoundLength - sizeInBits; if (preserveFirstAsSign && actualParameter.get(0)) { for (int i = 0; i < numPaddingBits; i++) { paddedSet.set(i); for (int i = numPaddingBits; i < byteBoundLength; i++) { ... |
BitSet | parseBitSet(byte[] sfData, int offset, int length) parse Bit Set BitSet bitSet = new BitSet(length * 8); int pos = 0; for (int i = 0; i < length; i++) { byte b = sfData[offset + i]; for (int j = 0; j < 8; j++) { boolean val = (b & (0x01 << 7 - j)) != 0; bitSet.set(pos, val); pos++; ... |
int | pickRandomSetIndexFromBitSet(BitSet bitset) pick Random Set Index From Bit Set if (bitset.isEmpty()) { throw new RuntimeException("The bitset is empty, cannot find a set element"); String set = bitset.toString(); String[] indexes = set.substring(1, set.length() - 1).split(","); return Integer.parseInt(indexes[(int) (Math.random() * (indexes.length - 1))].trim()); |
String | printBitSet(BitSet bs) print Bit Set return bs.toString();
|
void | printBitSet(BitSet iBits, int length) print Bit Set System.out.println("--------------------------------"); System.out.println("BitSet length is " + iBits.length()); System.out.println("length is " + length); for (int i = 0; i < length; i++) { if (((i - 1) % 8) == 0) { System.out.print(" "); if (iBits.get(i)) { ... |
byte | readByte(BitSet bits, int startByte) read Byte byte res = 0; for (int k = 0; k < 8; k++) { if (bits.get(startByte * 8 + k)) { res = (byte) (res | (1 << (7 - k))); return res; |
BitSet | reverse(final BitSet bitset, final int sizeInBits) reverse final BitSet reversed = new BitSet(); int reversedIndex = 0; for (int i = sizeInBits - 1; i >= 0; i--) { if (bitset.get(i)) { reversed.set(reversedIndex); reversedIndex++; return reversed; |