List of utility methods to do BitSet
BitSet | reverseBitSet(BitSet bs) Noddy method to reverse a BitSet. final BitSet copy = new BitSet(8); int counter = 0; int size = bs.length(); for (int i = 0; i < size; ++i) { if (i % 8 == 0 && i != 0) { for (int j = 8; j >= 1; j--) { bs.clear(i - j); if (copy.get(j - 1)) { ... |
Iterator | setBitIterator(final BitSet b) set Bit Iterator return new Iterator<Integer>() { int nextBit = b.nextSetBit(0); @Override public boolean hasNext() { return nextBit >= 0; @Override public Integer next() { ... |
void | setBits(BitSet bitSet, Iterable Set all bits on a given positions. for (Integer index : indexes) {
bitSet.set(index);
|
void | setBitSet(BitSet bitSet, int x1, int x2, int y, int width) set Bit Set int idx = width * y + x1; int idx2 = width * y + x2; for (; idx < idx2; idx++) { bitSet.set(idx); |
void | shiftLeft(BitSet bs, int n) shift Left for (int i = bs.length() - 1; i >= 0; i = bs.previousSetBit(i - 1)) { bs.clear(i); bs.set(i + 1); |
BitSet | shiftLeft(BitSet s, int length) Shifts bits of a BitSet object one place to the left. for (int i = length; i > 0; i--) { s.set(i, s.get(i - 1)); s.set(0, false); return s; |
BitSet | shiftLeft(BitSet src, int offset) shift Left if (offset < 0) return src; BitSet result = new BitSet(); int i; for (i = 0; i < src.length(); i++) { if (src.get(i)) { result.set(i + offset, true); return result; |
BitSet | shiftRight(BitSet bitset, int n) shift Right return bitset.get(n, Math.max(n, bitset.length()));
|
void | storeCharSet(BitSet stored, String... validCharStrings) store Char Set for (String validCharString : validCharStrings) { for (char c : validCharString.toCharArray()) { stored.set(c); |
BitSet | strArrToBitSet(String stringArray) Convert a String containing integers separated by space to an BitSet containing the integers as set members
BitSet bs = new BitSet(); StringTokenizer tk = new StringTokenizer(stringArray); while (tk.hasMoreTokens()) { Integer theInt = null; try { theInt = new Integer(tk.nextToken()); } catch (NumberFormatException e) { theInt = null; ... |