/** * Returns a new BTree with the provided collection inserting/replacing as necessary any equal items * * @param btree the tree to update * @param comparator the comparator that defines the ordering over the items in the tree * @param updateWith the items to either insert / update. MUST BE IN STRICTLY ASCENDING ORDER. * @param updateWithLength then number of elements in updateWith * @param updateF the update function to apply to any pairs we are swapping, and maybe abort early * @param <V> * @return */ public static <C, K extends C, V extends C> Object[] update(Object[] btree, Comparator<C> comparator, Iterable<K> updateWith, int updateWithLength, UpdateFunction<K, V> updateF) { if (isEmpty(btree)) return build(updateWith, updateWithLength, updateF); TreeBuilder builder = TreeBuilder.newInstance(); btree = builder.update(btree, comparator, updateWith, updateF); return btree; }
/** * Returns a new BTree with the provided collection inserting/replacing as necessary any equal items * * @param btree the tree to update * @param comparator the comparator that defines the ordering over the items in the tree * @param updateWith the items to either insert / update. MUST BE IN STRICTLY ASCENDING ORDER. * @param updateWithLength then number of elements in updateWith * @param updateF the update function to apply to any pairs we are swapping, and maybe abort early * @param <V> * @return */ public static <C, K extends C, V extends C> Object[] update(Object[] btree, Comparator<C> comparator, Iterable<K> updateWith, int updateWithLength, UpdateFunction<K, V> updateF) { if (isEmpty(btree)) return build(updateWith, updateWithLength, updateF); TreeBuilder builder = TreeBuilder.newInstance(); btree = builder.update(btree, comparator, updateWith, updateF); return btree; }
/** * Returns a new BTree with the provided collection inserting/replacing as necessary any equal items * * @param btree the tree to update * @param comparator the comparator that defines the ordering over the items in the tree * @param updateWith the items to either insert / update. MUST BE IN STRICTLY ASCENDING ORDER. * @param updateWithLength then number of elements in updateWith * @param updateF the update function to apply to any pairs we are swapping, and maybe abort early * @param <V> * @return */ public static <C, K extends C, V extends C> Object[] update(Object[] btree, Comparator<C> comparator, Iterable<K> updateWith, int updateWithLength, UpdateFunction<K, V> updateF) { if (isEmpty(btree)) return build(updateWith, updateWithLength, updateF); TreeBuilder builder = TreeBuilder.newInstance(); btree = builder.update(btree, comparator, updateWith, updateF); return btree; }
/** * Returns a new BTree with the provided collection inserting/replacing as necessary any equal items * * @param btree the tree to update * @param comparator the comparator that defines the ordering over the items in the tree * @param updateWith the items to either insert / update. MUST BE IN STRICTLY ASCENDING ORDER. * @param updateWithLength then number of elements in updateWith * @param updateF the update function to apply to any pairs we are swapping, and maybe abort early * @param <V> * @return */ public static <C, K extends C, V extends C> Object[] update(Object[] btree, Comparator<C> comparator, Iterable<K> updateWith, int updateWithLength, UpdateFunction<K, V> updateF) { if (isEmpty(btree)) return build(updateWith, updateWithLength, updateF); TreeBuilder builder = TreeBuilder.newInstance(); btree = builder.update(btree, comparator, updateWith, updateF); return btree; }