/** * Set bit at the given index to 'false'. * * @param i the index */ public void clear(int i) { int addr = i >> ADDRESS_BITS; if (addr >= data.length) { return; } data[addr] &= ~getBitMask(i); }
/** * Get the bit at the given index. * * @param i the index * @return true if the bit is enabled */ public boolean get(int i) { int addr = i >> ADDRESS_BITS; if (addr >= data.length) { return false; } return (data[addr] & getBitMask(i)) != 0; }
/** * Set bit at the given index to 'true'. * * @param i the index */ public void set(int i) { int addr = i >> ADDRESS_BITS; checkCapacity(addr); data[addr] |= getBitMask(i); if (maxLength < i) { maxLength = i; } }