org.apache.cassandra.utils.btree

## Class BTree

- java.lang.Object
- - org.apache.cassandra.utils.btree.BTree

    public class BTree
    extends java.lang.Object

### Constructor Summary

Constructors
Constructor and Description
`BTree()`

### Method Summary

All Methods Static Methods Concrete Methods
`static <V> java.lang.Object[]` `build(java.util.Collection<V> source, java.util.Comparator<V> comparator, boolean sorted, UpdateFunction<V> updateF)`
`static <V> java.lang.Object[]` `build(java.lang.Iterable<V> source, int size, java.util.Comparator<V> comparator, boolean sorted, UpdateFunction<V> updateF)` Creates a BTree containing all of the objects in the provided collection
`static int` `depth(java.lang.Object[] tree)`
`static java.lang.Object[]` `empty()` Returns an empty BTree
`static <V> V` `find(java.lang.Object[] node, java.util.Comparator<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> Cursor<V,V>` `slice(java.lang.Object[] btree, boolean forwards)` Returns an Iterator over the entire tree
`static <K,V extends K> Cursor<K,V>` `slice(java.lang.Object[] btree, java.util.Comparator<K> comparator, K start, boolean startInclusive, K end, boolean endInclusive, boolean forwards)` Returns an Iterator over a sub-range of the tree
`static <K,V extends K> Cursor<K,V>` `slice(java.lang.Object[] btree, java.util.Comparator<K> comparator, K start, K end, boolean forwards)` Returns an Iterator over a sub-range of the tree
`static <V> java.lang.Object[]` `update(java.lang.Object[] btree, java.util.Comparator<V> comparator, java.util.Collection<V> updateWith, boolean updateWithIsSorted)` Returns a new BTree with the provided set inserting/replacing as necessary any equal items
`static <V> java.lang.Object[]` `update(java.lang.Object[] btree, java.util.Comparator<V> comparator, java.util.Collection<V> updateWith, boolean updateWithIsSorted, UpdateFunction<V> updateF)`
`static <V> java.lang.Object[]` `update(java.lang.Object[] btree, java.util.Comparator<V> comparator, java.lang.Iterable<V> updateWith, int updateWithLength, boolean updateWithIsSorted, UpdateFunction<V> updateF)` Returns a new BTree with the provided set inserting/replacing as necessary any equal items

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### BTree

    public BTree()

### Method Detail

#### empty

    public static java.lang.Object[] empty()

Returns an empty BTree

Returns:

#### build

    public static <V> java.lang.Object[] build(java.util.Collection<V> source,
                                               java.util.Comparator<V> comparator,
                                               boolean sorted,
                                               UpdateFunction<V> updateF)

#### build

    public static <V> java.lang.Object[] build(java.lang.Iterable<V> source,
                                               int size,
                                               java.util.Comparator<V> comparator,
                                               boolean sorted,
                                               UpdateFunction<V> updateF)

Creates a BTree containing all of the objects in the provided collection

Type Parameters:
  `V` -
Parameters:
  `source` - the items to build the tree with
  `comparator` - the comparator that defines the ordering over the items in the tree
  `sorted` - if false, the collection will be copied and sorted to facilitate construction
Returns:

#### update

    public static <V> java.lang.Object[] update(java.lang.Object[] btree,
                                                java.util.Comparator<V> comparator,
                                                java.util.Collection<V> updateWith,
                                                boolean updateWithIsSorted)

Returns a new BTree with the provided set inserting/replacing as necessary any equal items

Type Parameters:
  `V` -
Parameters:
  `btree` - the tree to update
  `comparator` - the comparator that defines the ordering over the items in the tree
  `updateWith` - the items to either insert / update
  `updateWithIsSorted` - if false, updateWith will be copied and sorted to facilitate construction
Returns:

#### update

    public static <V> java.lang.Object[] update(java.lang.Object[] btree,
                                                java.util.Comparator<V> comparator,
                                                java.util.Collection<V> updateWith,
                                                boolean updateWithIsSorted,
                                                UpdateFunction<V> updateF)

#### update

    public static <V> java.lang.Object[] update(java.lang.Object[] btree,
                                                java.util.Comparator<V> comparator,
                                                java.lang.Iterable<V> updateWith,
                                                int updateWithLength,
                                                boolean updateWithIsSorted,
                                                UpdateFunction<V> updateF)

Returns a new BTree with the provided set inserting/replacing as necessary any equal items

Type Parameters:
  `V` -
Parameters:
  `btree` - the tree to update
  `comparator` - the comparator that defines the ordering over the items in the tree
  `updateWith` - the items to either insert / update
  `updateWithIsSorted` - if false, updateWith will be copied and sorted to facilitate construction
  `updateF` - the update function to apply to any pairs we are swapping, and maybe abort early
Returns:

#### slice

    public static <V> Cursor<V,V> slice(java.lang.Object[] btree,
                                        boolean forwards)

Returns an Iterator over the entire tree

Type Parameters:
  `V` -
Parameters:
  `btree` - the tree to iterate over
  `forwards` - if false, the iterator will start at the end and move backwards
Returns:

#### slice

    public static <K,V extends K> Cursor<K,V> slice(java.lang.Object[] btree,
                                                    java.util.Comparator<K> comparator,
                                                    K start,
                                                    K end,
                                                    boolean forwards)

Returns an Iterator over a sub-range of the tree

Type Parameters:
  `V` -
Parameters:
  `btree` - the tree to iterate over
  `comparator` - the comparator that defines the ordering over the items in the tree
  `start` - the first item to include
  `end` - the last item to include
  `forwards` - if false, the iterator will start at end and move backwards
Returns:

#### slice

    public static <K,V extends K> Cursor<K,V> slice(java.lang.Object[] btree,
                                                    java.util.Comparator<K> comparator,
                                                    K start,
                                                    boolean startInclusive,
                                                    K end,
                                                    boolean endInclusive,
                                                    boolean forwards)

Returns an Iterator over a sub-range of the tree

Type Parameters:
  `V` -
Parameters:
  `btree` - the tree to iterate over
  `comparator` - the comparator that defines the ordering over the items in the tree
  `start` - the first item to include
  `end` - the last item to include
  `forwards` - if false, the iterator will start at end and move backwards
Returns:

#### find

    public static <V> V find(java.lang.Object[] node,
                             java.util.Comparator<V> comparator,
                             V find)

#### isEmpty

    public static boolean isEmpty(java.lang.Object[] tree)

#### depth

    public static int depth(java.lang.Object[] tree)

#### isWellFormed

    public static boolean isWellFormed(java.lang.Object[] btree,
                                       java.util.Comparator<? extends java.lang.Object> cmp)