示例#1
0
  public <V> Object[] build(Iterable<V> source, UpdateFunction<V> updateF, int size) {
    assert updateF != null;

    NodeBuilder current = rootBuilder;
    // we descend only to avoid wasting memory; in update() we will often descend into existing
    // trees
    // so here we want to descend also, so we don't have lg max(N) depth in both directions
    while ((size >>= FAN_SHIFT) > 0) current = current.ensureChild();

    current.reset(EMPTY_LEAF, POSITIVE_INFINITY, updateF, null);
    for (V key : source) current.addNewKey(key);

    current = current.ascendToRoot();

    Object[] r = current.toNode();
    current.clear();
    return r;
  }