private BitSet(long[] bits) { this.bits = bits; this.longCount = bits.length; shrinkSize(); }
/** * Clears all bits in this {@code BitSet} which are also set in {@code bs}. */ public void andNot(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); for (int i = 0; i < minSize; ++i) { bits[i] &= ~bs.bits[i]; } shrinkSize(); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); // The serialized form doesn't include a 'longCount' field, so we'll have to scan the array. this.longCount = this.bits.length; shrinkSize(); } }
/** * Logically ands the bits of this {@code BitSet} with {@code bs}. */ public void and(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); for (int i = 0; i < minSize; ++i) { bits[i] &= bs.bits[i]; } Arrays.fill(bits, minSize, longCount, 0L); shrinkSize(); }
@Override public Object clone() { try { BitSet clone = (BitSet) super.clone(); clone.bits = bits.clone(); clone.shrinkSize(); return clone; } catch (CloneNotSupportedException e) { throw new AssertionError(e); } }
/** * Clears the bit at index {@code index}. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void clear(int index) { if (index < 0) { // TODO: until we have an inlining JIT. checkIndex(index); } int arrayIndex = index / 64; if (arrayIndex >= longCount) { return; } bits[arrayIndex] &= ~(1L << index); shrinkSize(); }
/** * Logically xors the bits of this {@code BitSet} with {@code bs}. */ public void xor(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); int maxSize = Math.max(this.longCount, bs.longCount); ensureCapacity(maxSize); for (int i = 0; i < minSize; ++i) { bits[i] ^= bs.bits[i]; } if (bs.longCount > minSize) { System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize); } longCount = maxSize; shrinkSize(); }
/** * Flips the bit at index {@code index}. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void flip(int index) { if (index < 0) { // TODO: until we have an inlining JIT. checkIndex(index); } int arrayIndex = index / 64; if (arrayIndex >= bits.length) { ensureCapacity(arrayIndex + 1); } bits[arrayIndex] ^= (1L << index); longCount = Math.max(longCount, arrayIndex + 1); shrinkSize(); }
private BitSet(long[] bits) { this.bits = bits; this.longCount = bits.length; shrinkSize(); }
private BitSet(long[] bits) { this.bits = bits; this.longCount = bits.length; shrinkSize(); }
/** * Clears all bits in this {@code BitSet} which are also set in {@code bs}. */ public void andNot(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); for (int i = 0; i < minSize; ++i) { bits[i] &= ~bs.bits[i]; } shrinkSize(); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); // The serialized form doesn't include a 'longCount' field, so we'll have to scan the array. this.longCount = this.bits.length; shrinkSize(); } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); // The serialized form doesn't include a 'longCount' field, so we'll have to scan the array. this.longCount = this.bits.length; shrinkSize(); } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); // The serialized form doesn't include a 'longCount' field, so we'll have to scan the array. this.longCount = this.bits.length; shrinkSize(); } }
/** * Clears all bits in this {@code BitSet} which are also set in {@code bs}. */ public void andNot(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); for (int i = 0; i < minSize; ++i) { bits[i] &= ~bs.bits[i]; } shrinkSize(); }
/** * Logically ands the bits of this {@code BitSet} with {@code bs}. */ public void and(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); for (int i = 0; i < minSize; ++i) { bits[i] &= bs.bits[i]; } Arrays.fill(bits, minSize, longCount, 0L); shrinkSize(); }
/** * Logically ands the bits of this {@code BitSet} with {@code bs}. */ public void and(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); for (int i = 0; i < minSize; ++i) { bits[i] &= bs.bits[i]; } Arrays.fill(bits, minSize, longCount, 0L); shrinkSize(); }
/** * Logically ands the bits of this {@code BitSet} with {@code bs}. */ public void and(BitSet bs) { int minSize = Math.min(this.longCount, bs.longCount); for (int i = 0; i < minSize; ++i) { bits[i] &= bs.bits[i]; } Arrays.fill(bits, minSize, longCount, 0L); shrinkSize(); }