Tenncor
Public Member Functions | Public Attributes | Private Member Functions | List of all members
PrettyTree< T > Struct Template Referencefinal

#include <tree.hpp>

Public Member Functions

 PrettyTree (std::function< std::vector< T >(T &)> traverser, std::function< void(std::ostream &, T &)> to_stream)
 
void print (std::ostream &out, T root)
 

Public Attributes

size_t branch_length_ = 2
 Horizontal length of the branch, by default the branch looks like `–. More...
 
std::function< std::vector< T >T &)> traverser_
 Behavior of traversing through a structure. More...
 
std::function< void(std::ostream &, T &)> to_stream_
 Behavior of displaying a node in the structure. More...
 

Private Member Functions

void print_helper (std::ostream &out, T root, std::string prefix)
 

Detailed Description

template<typename T>
struct PrettyTree< T >

Generically draw a traversible structure Traversible structure is anything having a parent-children relationship Template argument T defines one node of the traversible structure

Constructor & Destructor Documentation

◆ PrettyTree()

template<typename T>
PrettyTree< T >::PrettyTree ( std::function< std::vector< T >(T &)>  traverser,
std::function< void(std::ostream &, T &)>  to_stream 
)
inline

Traverser and streamer methods define behavior for traversing through and displaying elements of a generic structure

Member Function Documentation

◆ print()

template<typename T>
void PrettyTree< T >::print ( std::ostream &  out,
root 
)
inline

Given the output stream, and a root to start the traversal, wrap brackets around string representation of each node and connect each node with series of | and `– branches and stream to out

◆ print_helper()

template<typename T>
void PrettyTree< T >::print_helper ( std::ostream &  out,
root,
std::string  prefix 
)
inlineprivate

Member Data Documentation

◆ branch_length_

template<typename T>
size_t PrettyTree< T >::branch_length_ = 2

Horizontal length of the branch, by default the branch looks like `–.

◆ to_stream_

template<typename T>
std::function<void(std::ostream&,T&)> PrettyTree< T >::to_stream_

Behavior of displaying a node in the structure.

◆ traverser_

template<typename T>
std::function<std::vector<T>T&)> PrettyTree< T >::traverser_

Behavior of traversing through a structure.


The documentation for this struct was generated from the following file: