Пример #1
0
  public static Entry[] andNot(Entry[] a, Entry[] b) {
    if (Debug.ENABLED) {
      checkInvariants(a);
      checkInvariants(b);
    }

    if (Debug.ENABLED) { // Should not call for nothing
      boolean empty = true;

      for (int i = b.length - 1; i >= 0; i--) {
        if (b[i] != null) {
          Debug.assertion(b[i].Value != 0);
          empty = false;
        }
      }

      Debug.assertion(!empty);
    }

    Entry[] result = PlatformAdapter.createBitsArray(a.length);

    for (int i = a.length - 1; i >= 0; i--) if (a[i] != null) result[i] = andNot(a[i], b);

    return result;
  }
Пример #2
0
  public static final Entry[] set(Entry[] sparse, int index) {
    if (sparse == null)
      sparse = PlatformAdapter.createBitsArray(Bits.SPARSE_BITSET_DEFAULT_CAPACITY);

    while (!tryToSet(sparse, index)) sparse = reindex(sparse);

    return sparse;
  }
Пример #3
0
  private static final Entry[] reindex(Entry[] sparse) {
    Entry[] old = sparse;

    for (; ; ) {
      sparse = PlatformAdapter.createBitsArray(sparse.length << SparseArrayHelper.TIMES_TWO_SHIFT);

      if (reindex(old, sparse)) break;
    }

    return sparse;
  }