/** * Logically ors the bits of this {@code BitSet} with {@code bs}. */ public void or(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; }
/** * Sets the bit at index {@code index} to true. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void set(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); }
/** * 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(); }
int lastArrayIndex = (toIndex - 1) / 64; if (lastArrayIndex >= bits.length) { ensureCapacity(lastArrayIndex + 1);
/** * 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(); }
int lastArrayIndex = (toIndex - 1) / 64; if (lastArrayIndex >= bits.length) { ensureCapacity(lastArrayIndex + 1);
/** * Ensures that the BitSet can accommodate a given wordIndex, * temporarily violating the invariants. The caller must * restore the invariants before returning to the user, * possibly using recalculateWordsInUse(). * @param wordIndex the index to be accommodated. */ private void expandTo(int wordIndex) { int wordsRequired = wordIndex+1; if (wordsInUse < wordsRequired) { ensureCapacity(wordsRequired); wordsInUse = wordsRequired; } }
/** * Ensures that the BitSet can accommodate a given wordIndex, * temporarily violating the invariants. The caller must * restore the invariants before returning to the user, * possibly using recalculateWordsInUse(). * @param wordIndex the index to be accommodated. */ private void expandTo(int wordIndex) { int wordsRequired = wordIndex+1; if (wordsInUse < wordsRequired) { ensureCapacity(wordsRequired); wordsInUse = wordsRequired; } }
/** * Logically ors the bits of this {@code BitSet} with {@code bs}. */ public void or(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; }
/** * Logically ors the bits of this {@code BitSet} with {@code bs}. */ public void or(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; }
/** * Logically ors the bits of this {@code BitSet} with {@code bs}. */ public void or(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; }
/** * Logically ors the bits of this {@code BitSet} with {@code bs}. */ public void or(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; }
/** * Logically ors the bits of this {@code BitSet} with {@code bs}. */ public void or(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; }
/** * Logically ors the bits of this {@code BitSet} with {@code bs}. */ public void or(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; }
/** * Sets the bit at index {@code index} to true. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void set(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); }
/** * Sets the bit at index {@code index} to true. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void set(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); }
/** * 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(); }
/** * Sets the bit at index {@code index} to true. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void set(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); }
/** * Sets the bit at index {@code index} to true. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void set(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); }
/** * Sets the bit at index {@code index} to true. * * @throws IndexOutOfBoundsException if {@code index < 0}. */ public void set(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); }