This class is responsible for caching the path to each node of the tree. More...
Public Types | |
enum | PathFormat { FormatLR , FormatLR_ID , FormatID_LR } |
Possible formats to use for output. More... | |
Public Member Functions | |
template < typename MatType > | |
PathCacher (PathFormat fmt, DTree< MatType, int > *tree) | |
Construct a PathCacher object on the given tree with the given format. More... | |
template < typename MatType > | |
void | Enter (const DTree< MatType, int > *node, const DTree< MatType, int > *parent) |
Enter a given node. More... | |
template < typename MatType > | |
void | Leave (const DTree< MatType, int > *node, const DTree< MatType, int > *parent) |
Leave the given node. More... | |
size_t | NumNodes () const |
Get the number of nodes in the path cache. More... | |
int | ParentOf (int tag) const |
Get the parent tag of a given tag. More... | |
const std::string & | PathFor (int tag) const |
Return the constructed path for a given tag. More... | |
Protected Types | |
typedef std::vector< std::pair< int, std::string > > | PathCacheType |
typedef std::list< std::pair< bool, int > > | PathType |
Protected Member Functions | |
std::string | BuildString () |
Protected Attributes | |
PathFormat | format |
PathType | path |
PathCacheType | pathCache |
This class is responsible for caching the path to each node of the tree.
Its instance is provided to EnumerateTree() utility ONCE and it caches the paths to all the leafs and then easily (and quickly) retrieves these paths for each test entry.
Definition at line 81 of file dt_utils.hpp.
|
protected |
Definition at line 137 of file dt_utils.hpp.
Definition at line 136 of file dt_utils.hpp.
enum PathFormat |
Possible formats to use for output.
Enumerator | |
---|---|
FormatLR | Print only whether we went left or right. |
FormatLR_ID | Print the direction, then the tag of the node. |
FormatID_LR | Print the tag of the node, then the direction. |
Definition at line 87 of file dt_utils.hpp.
PathCacher | ( | PathFormat | fmt, |
DTree< MatType, int > * | tree | ||
) |
Construct a PathCacher object on the given tree with the given format.
fmt | Format to use for output. |
tree | Tree to cache paths in. |
|
inlineprotected |
Enter a given node.
Leave the given node.
|
inline |
Get the number of nodes in the path cache.
Definition at line 133 of file dt_utils.hpp.
References PathCacher::pathCache.
|
inline |
Get the parent tag of a given tag.
|
inline |
Return the constructed path for a given tag.
|
protected |
Definition at line 140 of file dt_utils.hpp.
|
protected |
Definition at line 139 of file dt_utils.hpp.
|
protected |
Definition at line 141 of file dt_utils.hpp.
Referenced by PathCacher::NumNodes().