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