mlpack
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
mlpack::det::PathCacher Class Reference

This class is responsible for caching the path to each node of the tree. More...

#include <dt_utils.hpp>

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.
 
template<typename MatType >
void Leave (const DTree< MatType, int > *node, const DTree< MatType, int > *parent)
 Leave the given node.
 
const std::string & PathFor (int tag) const
 Return the constructed path for a given tag.
 
int ParentOf (int tag) const
 Get the parent tag of a given tag.
 
size_t NumNodes () const
 Get the number of nodes in the path cache.
 

Protected Types

typedef std::list< std::pair< bool, int > > PathType
 
typedef std::vector< std::pair< int, std::string > > PathCacheType
 

Protected Member Functions

std::string BuildString ()
 

Protected Attributes

PathType path
 
PathFormat format
 
PathCacheType pathCache
 

Detailed Description

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.

Member Enumeration Documentation

◆ 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.

Constructor & Destructor Documentation

◆ PathCacher()

template<typename MatType >
mlpack::det::PathCacher::PathCacher ( PathCacher::PathFormat  fmt,
DTree< MatType, int > *  tree 
)

Construct a PathCacher object on the given tree with the given format.

Parameters
fmtFormat to use for output.
treeTree to cache paths in.

The documentation for this class was generated from the following files: