/** * Sets a bit. * * @param bit the bit to be set */ public void set(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] |= (1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit " + bit, e); } }
/** * Clears a bit. * * @param bit the bit to be cleared */ public void clear(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] &= ~(1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit: " + bit, e); } }
/** * Clears a bit. * * @param bit the bit to be cleared */ public void clear(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] &= ~(1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit: " + bit, e); } }
/** * Clears a bit. * * @param bit the bit to be cleared */ public void clear(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] &= ~(1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit: " + bit, e); } }
/** * Creates an empty string with the specified size. * * @param nbits the size of the string */ public FixedSizeBitVector(int nbits) { // subscript(nbits) is the length of the array needed to // hold nbits if (nbits < 0) { throw new IllegalArgumentException("illegal nbits: " + nbits); } bits = new int[subscript(nbits) + 1]; this.nbits = nbits; }
/** * Sets a bit. * * @param bit the bit to be set */ public void set(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] |= (1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit " + bit, e); } }
/** * Sets a bit. * * @param bit the bit to be set */ public void set(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] |= (1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit " + bit, e); } }
/** * Creates an empty string with the specified size. * * @param nbits the size of the string */ public FixedSizeBitVector(int nbits) { // subscript(nbits) is the length of the array needed to // hold nbits if (nbits < 0) { throw new IllegalArgumentException("illegal nbits: " + nbits); } bits = new int[subscript(nbits) + 1]; this.nbits = nbits; }
/** * Gets a bit. * * @param bit the bit to be gotten */ public boolean get(int bit) { if (bit < 0) { throw new IllegalArgumentException("illegal bit: " + bit); } int shiftBits = bit & LOW_MASK; int n = subscript(bit); try { return ((bits[n] & (1 << shiftBits)) != 0); } catch (ArrayIndexOutOfBoundsException e) { return false; } }
/** * Creates an empty string with the specified size. * * @param nbits the size of the string */ public FixedSizeBitVector(int nbits) { // subscript(nbits) is the length of the array needed to // hold nbits if (nbits < 0) { throw new IllegalArgumentException("illegal nbits: " + nbits); } bits = new int[subscript(nbits) + 1]; this.nbits = nbits; }
/** * Gets a bit. * * @param bit the bit to be gotten */ public boolean get(int bit) { if (bit < 0) { throw new IllegalArgumentException("illegal bit: " + bit); } int shiftBits = bit & LOW_MASK; int n = subscript(bit); try { return ((bits[n] & (1 << shiftBits)) != 0); } catch (ArrayIndexOutOfBoundsException e) { return false; } }
/** * Gets a bit. * * @param bit the bit to be gotten */ public boolean get(int bit) { if (bit < 0) { throw new IllegalArgumentException("illegal bit: " + bit); } int shiftBits = bit & LOW_MASK; int n = subscript(bit); try { return ((bits[n] & (1 << shiftBits)) != 0); } catch (ArrayIndexOutOfBoundsException e) { return false; } }