java.util.BitSet.ensureCapacity()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中java.util.BitSet.ensureCapacity()方法的一些代码示例,展示了BitSet.ensureCapacity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.ensureCapacity()方法的具体详情如下:
包路径:java.util.BitSet
类名称:BitSet
方法名:ensureCapacity

BitSet.ensureCapacity介绍

[英]Ensures that our long[] can hold at least 64 * desiredLongCount bits.
[中]确保我们的long[]可以容纳至少64*个所需的longcount位。

代码示例

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Logically ors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void or(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] |= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Sets the bit at index {@code index} to true.
  3. *
  4. * @throws IndexOutOfBoundsException if {@code index < 0}.
  5. */
  6. public void set(int index) {
  7. if (index < 0) { // TODO: until we have an inlining JIT.
  8. checkIndex(index);
  9. }
  10. int arrayIndex = index / 64;
  11. if (arrayIndex >= bits.length) {
  12. ensureCapacity(arrayIndex + 1);
  13. }
  14. bits[arrayIndex] |= (1L << index);
  15. longCount = Math.max(longCount, arrayIndex + 1);
  16. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Logically xors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void xor(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] ^= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. shrinkSize();
  16. }

代码示例来源:origin: robovm/robovm

  1. int lastArrayIndex = (toIndex - 1) / 64;
  2. if (lastArrayIndex >= bits.length) {
  3. ensureCapacity(lastArrayIndex + 1);

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Flips the bit at index {@code index}.
  3. *
  4. * @throws IndexOutOfBoundsException if {@code index < 0}.
  5. */
  6. public void flip(int index) {
  7. if (index < 0) { // TODO: until we have an inlining JIT.
  8. checkIndex(index);
  9. }
  10. int arrayIndex = index / 64;
  11. if (arrayIndex >= bits.length) {
  12. ensureCapacity(arrayIndex + 1);
  13. }
  14. bits[arrayIndex] ^= (1L << index);
  15. longCount = Math.max(longCount, arrayIndex + 1);
  16. shrinkSize();
  17. }

代码示例来源:origin: robovm/robovm

  1. int lastArrayIndex = (toIndex - 1) / 64;
  2. if (lastArrayIndex >= bits.length) {
  3. ensureCapacity(lastArrayIndex + 1);

代码示例来源:origin: org.apidesign.bck2brwsr/emul

  1. /**
  2. * Ensures that the BitSet can accommodate a given wordIndex,
  3. * temporarily violating the invariants. The caller must
  4. * restore the invariants before returning to the user,
  5. * possibly using recalculateWordsInUse().
  6. * @param wordIndex the index to be accommodated.
  7. */
  8. private void expandTo(int wordIndex) {
  9. int wordsRequired = wordIndex+1;
  10. if (wordsInUse < wordsRequired) {
  11. ensureCapacity(wordsRequired);
  12. wordsInUse = wordsRequired;
  13. }
  14. }

代码示例来源:origin: jtulach/bck2brwsr

  1. /**
  2. * Ensures that the BitSet can accommodate a given wordIndex,
  3. * temporarily violating the invariants. The caller must
  4. * restore the invariants before returning to the user,
  5. * possibly using recalculateWordsInUse().
  6. * @param wordIndex the index to be accommodated.
  7. */
  8. private void expandTo(int wordIndex) {
  9. int wordsRequired = wordIndex+1;
  10. if (wordsInUse < wordsRequired) {
  11. ensureCapacity(wordsRequired);
  12. wordsInUse = wordsRequired;
  13. }
  14. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Logically ors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void or(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] |= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Logically ors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void or(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] |= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. }

代码示例来源:origin: FlexoVM/flexovm

  1. /**
  2. * Logically ors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void or(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] |= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. }

代码示例来源:origin: com.gluonhq/robovm-rt

  1. /**
  2. * Logically ors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void or(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] |= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Logically ors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void or(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] |= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. }

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

  1. /**
  2. * Logically ors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void or(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] |= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. }

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

  1. /**
  2. * Sets the bit at index {@code index} to true.
  3. *
  4. * @throws IndexOutOfBoundsException if {@code index < 0}.
  5. */
  6. public void set(int index) {
  7. if (index < 0) { // TODO: until we have an inlining JIT.
  8. checkIndex(index);
  9. }
  10. int arrayIndex = index / 64;
  11. if (arrayIndex >= bits.length) {
  12. ensureCapacity(arrayIndex + 1);
  13. }
  14. bits[arrayIndex] |= (1L << index);
  15. longCount = Math.max(longCount, arrayIndex + 1);
  16. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Sets the bit at index {@code index} to true.
  3. *
  4. * @throws IndexOutOfBoundsException if {@code index < 0}.
  5. */
  6. public void set(int index) {
  7. if (index < 0) { // TODO: until we have an inlining JIT.
  8. checkIndex(index);
  9. }
  10. int arrayIndex = index / 64;
  11. if (arrayIndex >= bits.length) {
  12. ensureCapacity(arrayIndex + 1);
  13. }
  14. bits[arrayIndex] |= (1L << index);
  15. longCount = Math.max(longCount, arrayIndex + 1);
  16. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Logically xors the bits of this {@code BitSet} with {@code bs}.
  3. */
  4. public void xor(BitSet bs) {
  5. int minSize = Math.min(this.longCount, bs.longCount);
  6. int maxSize = Math.max(this.longCount, bs.longCount);
  7. ensureCapacity(maxSize);
  8. for (int i = 0; i < minSize; ++i) {
  9. bits[i] ^= bs.bits[i];
  10. }
  11. if (bs.longCount > minSize) {
  12. System.arraycopy(bs.bits, minSize, bits, minSize, maxSize - minSize);
  13. }
  14. longCount = maxSize;
  15. shrinkSize();
  16. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Sets the bit at index {@code index} to true.
  3. *
  4. * @throws IndexOutOfBoundsException if {@code index < 0}.
  5. */
  6. public void set(int index) {
  7. if (index < 0) { // TODO: until we have an inlining JIT.
  8. checkIndex(index);
  9. }
  10. int arrayIndex = index / 64;
  11. if (arrayIndex >= bits.length) {
  12. ensureCapacity(arrayIndex + 1);
  13. }
  14. bits[arrayIndex] |= (1L << index);
  15. longCount = Math.max(longCount, arrayIndex + 1);
  16. }

代码示例来源:origin: com.jtransc/jtransc-rt

  1. /**
  2. * Sets the bit at index {@code index} to true.
  3. *
  4. * @throws IndexOutOfBoundsException if {@code index < 0}.
  5. */
  6. public void set(int index) {
  7. if (index < 0) { // TODO: until we have an inlining JIT.
  8. checkIndex(index);
  9. }
  10. int arrayIndex = index / 64;
  11. if (arrayIndex >= bits.length) {
  12. ensureCapacity(arrayIndex + 1);
  13. }
  14. bits[arrayIndex] |= (1L << index);
  15. longCount = Math.max(longCount, arrayIndex + 1);
  16. }

代码示例来源:origin: com.gluonhq/robovm-rt

  1. /**
  2. * Sets the bit at index {@code index} to true.
  3. *
  4. * @throws IndexOutOfBoundsException if {@code index < 0}.
  5. */
  6. public void set(int index) {
  7. if (index < 0) { // TODO: until we have an inlining JIT.
  8. checkIndex(index);
  9. }
  10. int arrayIndex = index / 64;
  11. if (arrayIndex >= bits.length) {
  12. ensureCapacity(arrayIndex + 1);
  13. }
  14. bits[arrayIndex] |= (1L << index);
  15. longCount = Math.max(longCount, arrayIndex + 1);
  16. }

相关文章