gtsam
4.0.0
gtsam
|
Internal functions used for traversing trees. More...
Functions | |
template<class FOREST , typename DATA , typename VISITOR_PRE , typename VISITOR_POST > | |
void | DepthFirstForest (FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost) |
Traverse a forest depth-first with pre-order and post-order visits. More... | |
template<class FOREST , typename DATA , typename VISITOR_PRE > | |
void | DepthFirstForest (FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre) |
Traverse a forest depth-first, with a pre-order visit but no post-order visit. More... | |
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) |
Traverse a forest depth-first with pre-order and post-order visits. More... | |
template<class FOREST > | |
FastVector< boost::shared_ptr< typename FOREST::Node > > | CloneForest (const FOREST &forest) |
Clone a tree, copy-constructing new nodes (calling boost::make_shared) and setting up child pointers for a clone of the original tree. More... | |
template<class FOREST > | |
void | PrintForest (const FOREST &forest, std::string str, const KeyFormatter &keyFormatter) |
Print a tree, prefixing each line with str , and formatting keys using keyFormatter . More... | |
Internal functions used for traversing trees.
Traversal function for PrintForest.
Traversal function for CloneForest.
FastVector<boost::shared_ptr<typename FOREST::Node> > gtsam::treeTraversal::CloneForest | ( | const FOREST & | forest | ) |
Clone a tree, copy-constructing new nodes (calling boost::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 . |
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. |
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. |
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. |
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.