Package com.tdunning.math.stats

# Class GroupTree

java.lang.Object
com.tdunning.math.stats.GroupTree

All Implemented Interfaces:
  `Iterable<Centroid>`

public class GroupTree extends Object implements Iterable<Centroid>
A tree containing TDigest.Centroid. This adds to the normal NavigableSet the ability to sum up the size of elements to the left of a particular group.

## Constructor Summary

Constructors
Constructor
Description
`GroupTree()`
`GroupTree(Centroid leaf)`
`GroupTree(GroupTree left, GroupTree right)`

## Method Summary

Modifier and Type
Method
Description
`void`
`add(Centroid centroid)`
`Centroid`
`ceiling(Centroid base)`
`void`
`checkBalance()`
`Centroid`
`first()`
`Centroid`
`floor(Centroid base)`
`int`
`headCount(Centroid base)`
`long`
`headSum(Centroid base)`
`Iterator<Centroid>`
`iterator()`
Iteratres through all groups in the tree.
`Centroid`
`last()`
`void`
`move(double x, int count, Centroid v, Iterable<? extends Double> data)`
Modify an existing value in the tree subject to the constraint that the change will not alter the ordering of the tree.
`void`
`print(int depth)`
`void`
`remove(Centroid base)`
`int`
`size()`
`long`
`sum()`
`Iterable<Centroid>`
`tailSet(Centroid start)`

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

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

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

## Constructor Details

### GroupTree

public GroupTree()

### GroupTree

public GroupTree(Centroid leaf)

### GroupTree

public GroupTree(GroupTree left, GroupTree right)

## Method Details

### add

public void add(Centroid centroid)

### move

public void move(double x, int count, Centroid v, Iterable<? extends Double> data)
Modify an existing value in the tree subject to the constraint that the change will not alter the ordering of the tree.

Parameters:
  `x` - New value to add to Centroid
  `count` - Weight of new value
  `v` - The value to modify
  `data` - The recorded data

### size

public int size()

### headCount

public int headCount(Centroid base)

Returns:
  the number of items strictly before the current element

### headSum

public long headSum(Centroid base)

Returns:
  the sum of the size() function for all elements strictly before the current element.

### first

public Centroid first()

Returns:
  the first Centroid in this set

### iterator

public Iterator<Centroid> iterator()
Iteratres through all groups in the tree.

Specified by:
  `iterator` in interface `Iterable<Centroid>`

### remove

public void remove(Centroid base)

### floor

public Centroid floor(Centroid base)

Returns:
  the largest element less than or equal to base

### last

public Centroid last()

### ceiling

public Centroid ceiling(Centroid base)

Returns:
  the smallest element greater than or equal to base.

### tailSet

public Iterable<Centroid> tailSet(Centroid start)

Returns:
  the subset of elements equal to or greater than base.

### sum

public long sum()

### checkBalance

public void checkBalance()

### print

public void print(int depth)