Namespaces | Classes | Functions
gtsam::treeTraversal Namespace Reference

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 >
void DepthFirstForest (FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre)
 
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 , 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)
 

Detailed Description

Internal functions used for traversing trees

Traversal function for CloneForest

Traversal function for PrintForest

Function Documentation

◆ CloneForest()

template<class FOREST >
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.

Parameters
forestThe forest of trees to clone. The method forest.roots() should exist and return a collection of shared pointers to FOREST::Node.
Returns
The new collection of roots.

Definition at line 191 of file treeTraversal-inst.h.

◆ DepthFirstForest() [1/2]

template<class FOREST , typename DATA , typename VISITOR_PRE >
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.

Parameters
forestThe forest of trees to traverse. The method forest.roots() should exist and return a collection of (shared) pointers to FOREST::Node.
visitorPrevisitorPre(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.
rootDataThe data to pass by reference to visitorPre when it is called on each root node.

Definition at line 133 of file treeTraversal-inst.h.

◆ DepthFirstForest() [2/2]

template<class FOREST , typename DATA , typename VISITOR_PRE , typename VISITOR_POST >
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.

Parameters
forestThe forest of trees to traverse. The method forest.roots() should exist and return a collection of (shared) pointers to FOREST::Node.
visitorPrevisitorPre(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.
visitorPostvisitorPost(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).
rootDataThe data to pass by reference to visitorPre when it is called on each root node.

Definition at line 77 of file treeTraversal-inst.h.

◆ DepthFirstForestParallel()

template<class FOREST , typename DATA , typename VISITOR_PRE , typename VISITOR_POST >
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.

Parameters
forestThe forest of trees to traverse. The method forest.roots() should exist and return a collection of (shared) pointers to FOREST::Node.
rootDataThe data to pass by reference to visitorPre when it is called on each root node.
visitorPrevisitorPre(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.
visitorPostvisitorPost(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).
problemSizeThreshold

Definition at line 156 of file treeTraversal-inst.h.

◆ GatherStatistics()

template<class FOREST >
ForestStatistics gtsam::treeTraversal::GatherStatistics ( const FOREST &  forest)

Definition at line 86 of file statistics.h.

◆ PrintForest()

template<class FOREST >
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 221 of file treeTraversal-inst.h.



gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:24:59