コード例 #1
0
 @Override
 public RoaringArray clone() throws CloneNotSupportedException {
   RoaringArray sa;
   sa = (RoaringArray) super.clone();
   sa.array = Arrays.copyOf(this.array, this.size);
   for (int k = 0; k < this.size; ++k) sa.array[k] = sa.array[k].clone();
   sa.size = this.size;
   return sa;
 }
コード例 #2
0
  /**
   * Append copies of the values AFTER a specified key (may or may not be present) to end.
   *
   * @param sa the other array
   * @param beforeStart given key is the largest key that we won't copy
   */
  protected void appendCopiesAfter(RoaringArray sa, short beforeStart) {
    int startLocation = sa.getIndex(beforeStart);
    if (startLocation >= 0) startLocation++;
    else startLocation = -startLocation - 1;
    extendArray(sa.size - startLocation);

    for (int i = startLocation; i < sa.size; ++i) {
      this.array[this.size++] = new Element(sa.array[i].key, sa.array[i].value.clone());
    }
  }