public class BTree
extends java.lang.Object
| Modifier and Type | Class and Description | 
|---|---|
| static class  | BTree.Builder<V> | 
| static class  | BTree.Dir | 
| Constructor and Description | 
|---|
| BTree() | 
| Modifier and Type | Method and Description | 
|---|---|
| static <V> void | apply(java.lang.Object[] btree,
     java.util.function.Consumer<V> function,
     boolean reversed)Simple method to walk the btree forwards or reversed and apply a function to each element
 Public method | 
| static <V> void | apply(java.lang.Object[] btree,
     java.util.function.Consumer<V> function,
     com.google.common.base.Predicate<V> stopCondition,
     boolean reversed)Simple method to walk the btree forwards or reversed and apply a function till a stop condition is reached
 Public method | 
| static <C,K extends C,V extends C> | build(java.util.Collection<K> source,
     UpdateFunction<K,V> updateF) | 
| static <C,K extends C,V extends C> | build(java.lang.Iterable<K> source,
     int size,
     UpdateFunction<K,V> updateF)Creates a BTree containing all of the objects in the provided collection | 
| static <C,K extends C,V extends C> | build(java.lang.Iterable<K> source,
     UpdateFunction<K,V> updateF) | 
| static <V> BTree.Builder<V> | builder(java.util.Comparator<? super V> comparator) | 
| static <V> BTree.Builder<V> | builder(java.util.Comparator<? super V> comparator,
       int initialCapacity) | 
| static <V> V | ceil(java.lang.Object[] btree,
    java.util.Comparator<? super V> comparator,
    V find) | 
| static <V> int | ceilIndex(java.lang.Object[] btree,
         java.util.Comparator<? super V> comparator,
         V find) | 
| static int | depth(java.lang.Object[] tree) | 
| static java.lang.Object[] | empty() | 
| static boolean | equals(java.lang.Object[] a,
      java.lang.Object[] b) | 
| static <V> V | find(java.lang.Object[] node,
    java.util.Comparator<? super V> comparator,
    V find) | 
| static <V> V | findByIndex(java.lang.Object[] tree,
           int index) | 
| static <V> int | findIndex(java.lang.Object[] node,
         java.util.Comparator<? super V> comparator,
         V find)Honours result semantics of  Arrays.binarySearch(long[], long), as though it were performed on the tree flattened into an array | 
| static <V> V | floor(java.lang.Object[] btree,
     java.util.Comparator<? super V> comparator,
     V find) | 
| static <V> int | floorIndex(java.lang.Object[] btree,
          java.util.Comparator<? super V> comparator,
          V find) | 
| static int | hashCode(java.lang.Object[] btree) | 
| static <V> V | higher(java.lang.Object[] btree,
      java.util.Comparator<? super V> comparator,
      V find) | 
| static <V> int | higherIndex(java.lang.Object[] btree,
           java.util.Comparator<? super V> comparator,
           V find) | 
| static boolean | isEmpty(java.lang.Object[] tree) | 
| static boolean | isWellFormed(java.lang.Object[] btree,
            java.util.Comparator<? extends java.lang.Object> cmp) | 
| static <V> java.lang.Iterable<V> | iterable(java.lang.Object[] btree) | 
| static <V> java.lang.Iterable<V> | iterable(java.lang.Object[] btree,
        BTree.Dir dir) | 
| static <V> java.lang.Iterable<V> | iterable(java.lang.Object[] btree,
        int lb,
        int ub,
        BTree.Dir dir) | 
| static <V> java.util.Iterator<V> | iterator(java.lang.Object[] btree) | 
| static <V> java.util.Iterator<V> | iterator(java.lang.Object[] btree,
        BTree.Dir dir) | 
| static <V> java.util.Iterator<V> | iterator(java.lang.Object[] btree,
        int lb,
        int ub,
        BTree.Dir dir) | 
| static <V> V | lower(java.lang.Object[] btree,
     java.util.Comparator<? super V> comparator,
     V find) | 
| static <V> int | lowerIndex(java.lang.Object[] btree,
          java.util.Comparator<? super V> comparator,
          V find) | 
| static <K> java.lang.Object[] | merge(java.lang.Object[] tree1,
     java.lang.Object[] tree2,
     java.util.Comparator<? super K> comparator,
     UpdateFunction<K,K> updateF) | 
| static <V> void | replaceInSitu(java.lang.Object[] node,
             java.util.Comparator<? super V> comparator,
             V find,
             V replace)Modifies the provided btree directly. | 
| static <V> void | replaceInSitu(java.lang.Object[] tree,
             int index,
             V replace)Modifies the provided btree directly. | 
| static java.lang.Object[] | singleton(java.lang.Object value) | 
| static int | size(java.lang.Object[] tree) | 
| static long | sizeOfStructureOnHeap(java.lang.Object[] tree) | 
| static <K,V> BTreeSearchIterator<K,V> | slice(java.lang.Object[] btree,
     java.util.Comparator<? super K> comparator,
     BTree.Dir dir)Returns an Iterator over the entire tree | 
| static <K,V extends K> | slice(java.lang.Object[] btree,
     java.util.Comparator<? super K> comparator,
     K start,
     boolean startInclusive,
     K end,
     boolean endInclusive,
     BTree.Dir dir) | 
| static <K,V extends K> | slice(java.lang.Object[] btree,
     java.util.Comparator<? super K> comparator,
     K start,
     K end,
     BTree.Dir dir) | 
| static int | toArray(java.lang.Object[] tree,
       int treeStart,
       int treeEnd,
       java.lang.Object[] target,
       int targetOffset) | 
| static int | toArray(java.lang.Object[] tree,
       java.lang.Object[] target,
       int targetOffset)Fill the target array with the contents of the provided subtree, in ascending order, starting at targetOffset | 
| static <V> java.lang.Object[] | transformAndFilter(java.lang.Object[] btree,
                  com.google.common.base.Function<? super V,? extends V> function)Takes a btree and transforms it using the provided function, filtering out any null results. | 
| static int | treeIndexOfBranchKey(java.lang.Object[] root,
                    int keyIndex) | 
| static int | treeIndexOffsetOfChild(java.lang.Object[] root,
                      int childIndex) | 
| static int | treeIndexOfKey(java.lang.Object[] root,
              int keyIndex)tree index => index of key wrt all items in the tree laid out serially
 This version of the method permits requesting out-of-bounds indexes, -1 and size | 
| static int | treeIndexOfLeafKey(int keyIndex) | 
| static <C,K extends C,V extends C> | update(java.lang.Object[] btree,
      java.util.Comparator<C> comparator,
      java.util.Collection<K> updateWith,
      UpdateFunction<K,V> updateF) | 
| static <C,K extends C,V extends C> | update(java.lang.Object[] btree,
      java.util.Comparator<C> comparator,
      java.lang.Iterable<K> updateWith,
      int updateWithLength,
      UpdateFunction<K,V> updateF)Returns a new BTree with the provided collection inserting/replacing as necessary any equal items | 
public static java.lang.Object[] empty()
public static java.lang.Object[] singleton(java.lang.Object value)
public static <C,K extends C,V extends C> java.lang.Object[] build(java.util.Collection<K> source,
                                                                   UpdateFunction<K,V> updateF)
public static <C,K extends C,V extends C> java.lang.Object[] build(java.lang.Iterable<K> source,
                                                                   UpdateFunction<K,V> updateF)
public static <C,K extends C,V extends C> java.lang.Object[] build(java.lang.Iterable<K> source,
                                                                   int size,
                                                                   UpdateFunction<K,V> updateF)
source - the items to build the tree with. MUST BE IN STRICTLY ASCENDING ORDER.size - the size of the source iterablepublic static <C,K extends C,V extends C> java.lang.Object[] update(java.lang.Object[] btree,
                                                                    java.util.Comparator<C> comparator,
                                                                    java.util.Collection<K> updateWith,
                                                                    UpdateFunction<K,V> updateF)
public static <C,K extends C,V extends C> java.lang.Object[] update(java.lang.Object[] btree,
                                                                    java.util.Comparator<C> comparator,
                                                                    java.lang.Iterable<K> updateWith,
                                                                    int updateWithLength,
                                                                    UpdateFunction<K,V> updateF)
V - btree - the tree to updatecomparator - the comparator that defines the ordering over the items in the treeupdateWith - the items to either insert / update. MUST BE IN STRICTLY ASCENDING ORDER.updateWithLength - then number of elements in updateWithupdateF - the update function to apply to any pairs we are swapping, and maybe abort earlypublic static <K> java.lang.Object[] merge(java.lang.Object[] tree1,
                                           java.lang.Object[] tree2,
                                           java.util.Comparator<? super K> comparator,
                                           UpdateFunction<K,K> updateF)
public static <V> java.util.Iterator<V> iterator(java.lang.Object[] btree)
public static <V> java.util.Iterator<V> iterator(java.lang.Object[] btree,
                                                 BTree.Dir dir)
public static <V> java.util.Iterator<V> iterator(java.lang.Object[] btree,
                                                 int lb,
                                                 int ub,
                                                 BTree.Dir dir)
public static <V> java.lang.Iterable<V> iterable(java.lang.Object[] btree)
public static <V> java.lang.Iterable<V> iterable(java.lang.Object[] btree,
                                                 BTree.Dir dir)
public static <V> java.lang.Iterable<V> iterable(java.lang.Object[] btree,
                                                 int lb,
                                                 int ub,
                                                 BTree.Dir dir)
public static <K,V> BTreeSearchIterator<K,V> slice(java.lang.Object[] btree, java.util.Comparator<? super K> comparator, BTree.Dir dir)
V - btree - the tree to iterate overdir - direction of iterationpublic static <K,V extends K> BTreeSearchIterator<K,V> slice(java.lang.Object[] btree, java.util.Comparator<? super K> comparator, K start, K end, BTree.Dir dir)
btree - the tree to iterate overcomparator - the comparator that defines the ordering over the items in the treestart - the beginning of the range to return, inclusive (in ascending order)end - the end of the range to return, exclusive (in ascending order)dir - if false, the iterator will start at the last item and move backwardspublic static <K,V extends K> BTreeSearchIterator<K,V> slice(java.lang.Object[] btree, java.util.Comparator<? super K> comparator, K start, boolean startInclusive, K end, boolean endInclusive, BTree.Dir dir)
btree - the tree to iterate overcomparator - the comparator that defines the ordering over the items in the treestart - low bound of the rangestartInclusive - inclusivity of lower boundend - high bound of the rangeendInclusive - inclusivity of higher bounddir - direction of iterationpublic static <V> V find(java.lang.Object[] node,
                         java.util.Comparator<? super V> comparator,
                         V find)
public static <V> void replaceInSitu(java.lang.Object[] tree,
                                     int index,
                                     V replace)
public static <V> void replaceInSitu(java.lang.Object[] node,
                                     java.util.Comparator<? super V> comparator,
                                     V find,
                                     V replace)
public static <V> int findIndex(java.lang.Object[] node,
                                java.util.Comparator<? super V> comparator,
                                V find)
Arrays.binarySearch(long[], long), as though it were performed on the tree flattened into an arraypublic static <V> V findByIndex(java.lang.Object[] tree,
                                int index)
public static <V> int lowerIndex(java.lang.Object[] btree,
                                 java.util.Comparator<? super V> comparator,
                                 V find)
public static <V> V lower(java.lang.Object[] btree,
                          java.util.Comparator<? super V> comparator,
                          V find)
public static <V> int floorIndex(java.lang.Object[] btree,
                                 java.util.Comparator<? super V> comparator,
                                 V find)
public static <V> V floor(java.lang.Object[] btree,
                          java.util.Comparator<? super V> comparator,
                          V find)
public static <V> int higherIndex(java.lang.Object[] btree,
                                  java.util.Comparator<? super V> comparator,
                                  V find)
public static <V> V higher(java.lang.Object[] btree,
                           java.util.Comparator<? super V> comparator,
                           V find)
public static <V> int ceilIndex(java.lang.Object[] btree,
                                java.util.Comparator<? super V> comparator,
                                V find)
public static <V> V ceil(java.lang.Object[] btree,
                         java.util.Comparator<? super V> comparator,
                         V find)
public static int size(java.lang.Object[] tree)
public static long sizeOfStructureOnHeap(java.lang.Object[] tree)
public static boolean isEmpty(java.lang.Object[] tree)
public static int depth(java.lang.Object[] tree)
public static int toArray(java.lang.Object[] tree,
                          java.lang.Object[] target,
                          int targetOffset)
tree - sourcetarget - arraytargetOffset - offset in target arraypublic static int toArray(java.lang.Object[] tree,
                          int treeStart,
                          int treeEnd,
                          java.lang.Object[] target,
                          int targetOffset)
public static <V> java.lang.Object[] transformAndFilter(java.lang.Object[] btree,
                                                        com.google.common.base.Function<? super V,? extends V> function)
public static boolean equals(java.lang.Object[] a,
                             java.lang.Object[] b)
public static int hashCode(java.lang.Object[] btree)
public static int treeIndexOfKey(java.lang.Object[] root,
                                 int keyIndex)
root - to calculate tree index withinkeyIndex - root-local index of key to calculate tree-indexpublic static int treeIndexOfLeafKey(int keyIndex)
keyIndex - node-local index of the key to calculate index ofpublic static int treeIndexOfBranchKey(java.lang.Object[] root,
                                       int keyIndex)
root - to calculate tree-index withinkeyIndex - root-local index of key to calculate tree-index ofpublic static int treeIndexOffsetOfChild(java.lang.Object[] root,
                                         int childIndex)
root - to calculate tree-index withinchildIndex - root-local index of *child* to calculate tree-index ofpublic static <V> BTree.Builder<V> builder(java.util.Comparator<? super V> comparator)
public static <V> BTree.Builder<V> builder(java.util.Comparator<? super V> comparator, int initialCapacity)
public static boolean isWellFormed(java.lang.Object[] btree,
                                   java.util.Comparator<? extends java.lang.Object> cmp)
public static <V> void apply(java.lang.Object[] btree,
                             java.util.function.Consumer<V> function,
                             boolean reversed)
public static <V> void apply(java.lang.Object[] btree,
                             java.util.function.Consumer<V> function,
                             com.google.common.base.Predicate<V> stopCondition,
                             boolean reversed)
Copyright © 2018 The Apache Software Foundation