Namespaces | |
internal | |
Classes | |
struct | ForestStatistics |
Struct to store gathered statistics about a forest. More... | |
Functions | |
template<class FOREST > | |
FastVector< std::shared_ptr< typename FOREST::Node > > | CloneForest (const FOREST &forest) |
template<class FOREST , typename DATA , typename VISITOR_PRE , typename VISITOR_POST > | |
void | DepthFirstForest (FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost) |
template<class FOREST , typename DATA , typename VISITOR_PRE > | |
void | DepthFirstForest (FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre) |
template<class FOREST , typename DATA , typename VISITOR_PRE , typename VISITOR_POST > | |
void | DepthFirstForestParallel (FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost, int problemSizeThreshold=10) |
template<class FOREST > | |
ForestStatistics | GatherStatistics (const FOREST &forest) |
template<class FOREST > | |
void | PrintForest (const FOREST &forest, std::string str, const KeyFormatter &keyFormatter) |
Internal functions used for traversing trees
Traversal function for CloneForest
Traversal function for PrintForest
FastVector<std::shared_ptr<typename FOREST::Node> > gtsam::treeTraversal::CloneForest | ( | const FOREST & | forest | ) |
Clone a tree, copy-constructing new nodes (calling std::make_shared) and setting up child pointers for a clone of the original tree.
forest | The forest of trees to clone. The method forest.roots() should exist and return a collection of shared pointers to FOREST::Node . |
Definition at line 189 of file treeTraversal-inst.h.
void gtsam::treeTraversal::DepthFirstForest | ( | FOREST & | forest, |
DATA & | rootData, | ||
VISITOR_PRE & | visitorPre, | ||
VISITOR_POST & | visitorPost | ||
) |
Traverse a forest depth-first with pre-order and post-order visits.
forest | The forest of trees to traverse. The method forest.roots() should exist and return a collection of (shared) pointers to FOREST::Node . |
visitorPre | visitorPre(node, parentData) will be called at every node, before visiting its children, and will be passed, by reference, the DATA object returned by the visit to its parent. Likewise, visitorPre should return the DATA object to pass to the children. The returned DATA object will be copy-constructed only upon returning to store internally, thus may be modified by visiting the children. Regarding efficiency, this copy-on-return is usually optimized out by the compiler. |
visitorPost | visitorPost(node, data) will be called at every node, after visiting its children, and will be passed, by reference, the DATA object returned by the call to visitorPre (the DATA object may be modified by visiting the children). |
rootData | The data to pass by reference to visitorPre when it is called on each root node. |
Definition at line 77 of file treeTraversal-inst.h.
void gtsam::treeTraversal::DepthFirstForest | ( | FOREST & | forest, |
DATA & | rootData, | ||
VISITOR_PRE & | visitorPre | ||
) |
Traverse a forest depth-first, with a pre-order visit but no post-order visit.
forest | The forest of trees to traverse. The method forest.roots() should exist and return a collection of (shared) pointers to FOREST::Node . |
visitorPre | visitorPre(node, parentData) will be called at every node, before visiting its children, and will be passed, by reference, the DATA object returned by the visit to its parent. Likewise, visitorPre should return the DATA object to pass to the children. The returned DATA object will be copy-constructed only upon returning to store internally, thus may be modified by visiting the children. Regarding efficiency, this copy-on-return is usually optimized out by the compiler. |
rootData | The data to pass by reference to visitorPre when it is called on each root node. |
Definition at line 133 of file treeTraversal-inst.h.
void gtsam::treeTraversal::DepthFirstForestParallel | ( | FOREST & | forest, |
DATA & | rootData, | ||
VISITOR_PRE & | visitorPre, | ||
VISITOR_POST & | visitorPost, | ||
int | problemSizeThreshold = 10 |
||
) |
Traverse a forest depth-first with pre-order and post-order visits.
forest | The forest of trees to traverse. The method forest.roots() should exist and return a collection of (shared) pointers to FOREST::Node . |
visitorPre | visitorPre(node, parentData) will be called at every node, before visiting its children, and will be passed, by reference, the DATA object returned by the visit to its parent. Likewise, visitorPre should return the DATA object to pass to the children. The returned DATA object will be copy-constructed only upon returning to store internally, thus may be modified by visiting the children. Regarding efficiency, this copy-on-return is usually optimized out by the compiler. |
visitorPost | visitorPost(node, data) will be called at every node, after visiting its children, and will be passed, by reference, the DATA object returned by the call to visitorPre (the DATA object may be modified by visiting the children). |
rootData | The data to pass by reference to visitorPre when it is called on each root node. |
Definition at line 154 of file treeTraversal-inst.h.
ForestStatistics gtsam::treeTraversal::GatherStatistics | ( | const FOREST & | forest | ) |
Definition at line 86 of file statistics.h.
void gtsam::treeTraversal::PrintForest | ( | const FOREST & | forest, |
std::string | str, | ||
const KeyFormatter & | keyFormatter | ||
) |
Print a tree, prefixing each line with str
, and formatting keys using keyFormatter
. To print each node, this function calls the print
function of the tree nodes.
Definition at line 219 of file treeTraversal-inst.h.