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

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

本文整理了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

/**
 * 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;
}

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

/**
 * 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);
}

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

/**
 * 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();
}

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

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

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

/**
 * 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();
}

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

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

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

/**
 * 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;
  }
}

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

/**
 * 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;
  }
}

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

/**
 * 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;
}

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

/**
 * 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;
}

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

/**
 * 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;
}

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

/**
 * 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;
}

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

/**
 * 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;
}

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

/**
 * 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;
}

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

/**
 * 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);
}

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

/**
 * 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);
}

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

/**
 * 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();
}

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

/**
 * 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);
}

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

/**
 * 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);
}

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

/**
 * 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);
}

相关文章