cheshirekow
v0.1.0
|
implements a binary tree of partial sums for sampling from discrete distributions with arbitrary weight More...
#include <mpblocks/btps/tree.h>
Public Types | |
typedef Traits::NodeOps | NodeOps |
typedef Traits::NodeRef | NodeRef |
Public Member Functions | |
void | clear () |
clear out the tree (does not free nodes) More... | |
template<typename T > | |
NodeRef | findInterval (T val) |
given $ val [0,1] $, sample a node from the weighted distribution More... | |
void | generateDepthProfile (std::map< int, std::list< NodeRef > > &depthMap) |
fill depthMap with a list of nodes at each depth More... | |
void | insert (NodeRef x) |
insert a single node into the tree, weight(x) must be set, all other fields are initialized by the tree More... | |
void | remove (NodeRef x) |
remove node from the tree and maintain balance More... | |
NodeRef | root () |
return the root node in the tree More... | |
size_t | size () |
return the count of nodes in the tree More... | |
auto | sum () -> decltype(ops_.CumulativeWeight(root_)) |
return the total weight of all nodes in the tree More... | |
Tree (NodeRef Nil) | |
initialize a tree using Nil as the sentinal object More... | |
double | validateTree () |
return the largest difference between cum(x) and the computed value over all nodes in the tree More... | |
Private Member Functions | |
auto | count (NodeRef N) -> decltype(ops_.Count(N)) |
auto | cum (NodeRef N) -> decltype(ops_.CumulativeWeight(N)) |
NodeRef | deepestLeaf (NodeRef p) |
find the deepest leaf in a subtree More... | |
template<typename T > | |
NodeRef | findInterval (NodeRef x, T val) |
given $ val [0,1] $, sample a node from the weighted distribution over the subtree rooted at x More... | |
void | insert (NodeRef p, NodeRef x) |
recursively insert x in the subtree rooted at p More... | |
bool | isLeaf (NodeRef x) |
true if x is a leaf node (i.e. both children are Nil) More... | |
NodeRef & | left (NodeRef N) |
NodeRef & | parent (NodeRef N) |
void | removeLeaf (NodeRef x) |
remove a leaf node from the tree More... | |
NodeRef & | right (NodeRef N) |
void | swap (NodeRef a, NodeRef b) |
swaps everything but the weight and cumulative weight More... | |
void | update (NodeRef x) |
update a node's count and cumulative weight by summing the count/weight of itself with the cumulative count/weight of it's children More... | |
void | updateAncestry (NodeRef p) |
walk the tree along the parent path from p to the root and update all nodes on that path More... | |
double | validateNode (NodeRef x) |
return the larger of the error of cum(x) or the error of it's children More... | |
auto | weight (NodeRef N) -> decltype(ops_.Weight(N)) |
Private Attributes | |
NodeRef | nil_ |
NodeOps | ops_ |
NodeRef | root_ |
implements a binary tree of partial sums for sampling from discrete distributions with arbitrary weight
typedef Traits::NodeOps mpblocks::btps::Tree< Traits >::NodeOps |
typedef Traits::NodeRef mpblocks::btps::Tree< Traits >::NodeRef |
|
inline |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inline |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
private |
|
private |
|
private |