/** * As build(), except: * @param size < 0 if size is unknown */ private static <C, K extends C, V extends C> Object[] buildInternal(Iterable<K> source, int size, UpdateFunction<K, V> updateF) { if ((size >= 0) & (size < FAN_FACTOR)) { if (size == 0) return EMPTY_LEAF; // pad to odd length to match contract that all leaf nodes are odd V[] values = (V[]) new Object[size | 1]; { int i = 0; for (K k : source) values[i++] = updateF.apply(k); } if (updateF != UpdateFunction.noOp()) updateF.allocated(ObjectSizes.sizeOfArray(values)); return values; } TreeBuilder builder = TreeBuilder.newInstance(); Object[] btree = builder.build(source, updateF, size); return btree; }
public Object[] build() { if (auto) autoEnforce(); return BTree.build(Arrays.asList(values).subList(0, count), UpdateFunction.noOp()); } }
void addNewKey(Object key) { ensureRoom(buildKeyPosition + 1); buildKeys[buildKeyPosition++] = updateFunction.apply(key); }
private Object[] buildFromRange(int offset, int keyLength, boolean isLeaf, boolean isExtra) { // if keyLength is 0, we didn't copy anything from the original, which means we didn't // modify any of the range owned by it, so can simply return it as is if (keyLength == 0) return copyFrom; Object[] a; if (isLeaf) { a = new Object[keyLength + (keyLength & 1)]; System.arraycopy(buildKeys, offset, a, 0, keyLength); } else { a = new Object[1 + (keyLength * 2)]; System.arraycopy(buildKeys, offset, a, 0, keyLength); System.arraycopy(buildChildren, offset, a, keyLength, keyLength + 1); } if (isExtra) updateFunction.allocated(ObjectSizes.sizeOfArray(a)); else if (a.length != copyFrom.length) updateFunction.allocated(ObjectSizes.sizeOfArray(a) - (copyFrom.length == 0 ? 0 : ObjectSizes.sizeOfArray(copyFrom))); return a; }
public static <V extends Comparable<V>> BTreeSet<V> of(V value) { return new BTreeSet<>(BTree.build(ImmutableList.of(value), UpdateFunction.<V>noOp()), Ordering.<V>natural()); }
void addNewKey(Object key) { ensureRoom(buildKeyPosition + 1); buildKeys[buildKeyPosition++] = updateFunction.apply(key); }
/** * As build(), except: * @param size < 0 if size is unknown */ private static <C, K extends C, V extends C> Object[] buildInternal(Iterable<K> source, int size, UpdateFunction<K, V> updateF) { if ((size >= 0) & (size < FAN_FACTOR)) { if (size == 0) return EMPTY_LEAF; // pad to odd length to match contract that all leaf nodes are odd V[] values = (V[]) new Object[size | 1]; { int i = 0; for (K k : source) values[i++] = updateF.apply(k); } if (updateF != UpdateFunction.noOp()) updateF.allocated(ObjectSizes.sizeOfArray(values)); return values; } TreeBuilder builder = TreeBuilder.newInstance(); Object[] btree = builder.build(source, updateF, size); return btree; }
public Object[] build() { if (auto) autoEnforce(); return BTree.build(Arrays.asList(values).subList(0, count), UpdateFunction.noOp()); } }
void addNewKey(Object key) { ensureRoom(buildKeyPosition + 1); buildKeys[buildKeyPosition++] = updateFunction.apply(key); }
if (updateF.abortEarly())
/** * As build(), except: * @param size < 0 if size is unknown */ private static <C, K extends C, V extends C> Object[] buildInternal(Iterable<K> source, int size, UpdateFunction<K, V> updateF) { if ((size >= 0) & (size < FAN_FACTOR)) { if (size == 0) return EMPTY_LEAF; // pad to odd length to match contract that all leaf nodes are odd V[] values = (V[]) new Object[size | 1]; { int i = 0; for (K k : source) values[i++] = updateF.apply(k); } if (updateF != UpdateFunction.noOp()) updateF.allocated(ObjectSizes.sizeOfArray(values)); return values; } TreeBuilder builder = TreeBuilder.newInstance(); Object[] btree = builder.build(source, updateF, size); return btree; }
public static <V extends Comparable<V>> BTreeSet<V> of(V value) { return new BTreeSet<>(BTree.build(ImmutableList.of(value), UpdateFunction.<V>noOp()), Ordering.<V>natural()); }
void addNewKey(Object key) { ensureRoom(buildKeyPosition + 1); buildKeys[buildKeyPosition++] = updateFunction.apply(key); }
if (updateF.abortEarly())