CPPX 3.2.1
A Modern C++ Utility Library
Loading...
Searching...
No Matches
stl_ext::BinaryTree< T > Class Template Reference

#include <cppx.h>

Inheritance diagram for stl_ext::BinaryTree< T >:
Collaboration diagram for stl_ext::BinaryTree< T >:

Public Member Functions

 BinaryTree ()=default
 
 BinaryTree (const BinaryTree &other)
 
BinaryTree & operator= (const BinaryTree &other)
 
 BinaryTree (BinaryTree &&other) noexcept
 
BinaryTree & operator= (BinaryTree &&other) noexcept
 
virtual ~BinaryTree ()
 
Node< T > * get_root () const
 
void set_root (Node< T > *root)
 
bool is_empty () const
 
int size () const
 
void print_preorder () const
 
void print_inorder () const
 
void print_postorder () const
 
void print_levelorder () const
 
void print_tree () const
 
void dump_to_dot (const std::string &filename) const
 
Node< T > * make_node (const T &val)
 
Node< T > * make_node (const T &val, Node< T > *left, Node< T > *right)
 
void set_left (Node< T > *parent, Node< T > *left_child)
 
void set_right (Node< T > *parent, Node< T > *right_child)
 
void clear ()
 
virtual int height () const
 
int count_leaves () const
 

Protected Member Functions

void preorder (const Node< T > *node) const
 
void inorder (const Node< T > *node) const
 
void postorder (const Node< T > *node) const
 
void levelorder (const Node< T > *node) const
 
int compute_size (const Node< T > *node) const
 
void print_tree_helper (const Node< T > *node, const std::string &prefix, bool is_left) const
 
void dot_helper (const Node< T > *node, std::ostream &out, int &null_count) const
 
void destroy_subtree (Node< T > *node)
 
Node< T > * clone_subtree (const Node< T > *node)
 

Protected Attributes

Node< T > * p_head = nullptr
 
NodePool< T > m_pool
 

Detailed Description

template<typename T>
class stl_ext::BinaryTree< T >

Definition at line 93 of file cppx.h.

Constructor & Destructor Documentation

◆ BinaryTree() [1/3]

template<typename T >
stl_ext::BinaryTree< T >::BinaryTree ( )
default

◆ BinaryTree() [2/3]

template<typename T >
stl_ext::BinaryTree< T >::BinaryTree ( const BinaryTree< T > &  other)

Definition at line 119 of file binary_tree.tpp.

◆ BinaryTree() [3/3]

template<typename T >
stl_ext::BinaryTree< T >::BinaryTree ( BinaryTree< T > &&  other)
noexcept

Definition at line 136 of file binary_tree.tpp.

◆ ~BinaryTree()

template<typename T >
stl_ext::BinaryTree< T >::~BinaryTree ( )
virtual

Definition at line 152 of file binary_tree.tpp.

Member Function Documentation

◆ clear()

template<typename T >
void stl_ext::BinaryTree< T >::clear ( )

Definition at line 14 of file binary_tree.tpp.

◆ clone_subtree()

template<typename T >
Node< T > * stl_ext::BinaryTree< T >::clone_subtree ( const Node< T > *  node)
protected

Definition at line 62 of file binary_tree.tpp.

◆ compute_size()

template<typename T >
int stl_ext::BinaryTree< T >::compute_size ( const Node< T > *  node) const
protected

Definition at line 240 of file binary_tree.tpp.

◆ count_leaves()

template<typename T >
int stl_ext::BinaryTree< T >::count_leaves ( ) const

Definition at line 424 of file binary_tree.tpp.

◆ destroy_subtree()

template<typename T >
void stl_ext::BinaryTree< T >::destroy_subtree ( Node< T > *  node)
protected

Definition at line 44 of file binary_tree.tpp.

◆ dot_helper()

template<typename T >
void stl_ext::BinaryTree< T >::dot_helper ( const Node< T > *  node,
std::ostream &  out,
int &  null_count 
) const
protected

Definition at line 373 of file binary_tree.tpp.

◆ dump_to_dot()

template<typename T >
void stl_ext::BinaryTree< T >::dump_to_dot ( const std::string &  filename) const

Definition at line 403 of file binary_tree.tpp.

◆ get_root()

template<typename T >
Node< T > * stl_ext::BinaryTree< T >::get_root ( ) const

Definition at line 260 of file binary_tree.tpp.

◆ height()

template<typename T >
int stl_ext::BinaryTree< T >::height ( ) const
virtual

Reimplemented in stl_ext::AVLTree< T >.

Definition at line 20 of file binary_tree.tpp.

◆ inorder()

template<typename T >
void stl_ext::BinaryTree< T >::inorder ( const Node< T > *  node) const
protected

Definition at line 175 of file binary_tree.tpp.

◆ is_empty()

template<typename T >
bool stl_ext::BinaryTree< T >::is_empty ( ) const

Definition at line 274 of file binary_tree.tpp.

◆ levelorder()

template<typename T >
void stl_ext::BinaryTree< T >::levelorder ( const Node< T > *  node) const
protected

Definition at line 222 of file binary_tree.tpp.

◆ make_node() [1/2]

template<typename T >
Node< T > * stl_ext::BinaryTree< T >::make_node ( const T &  val)

Definition at line 333 of file binary_tree.tpp.

◆ make_node() [2/2]

template<typename T >
Node< T > * stl_ext::BinaryTree< T >::make_node ( const T &  val,
Node< T > *  left,
Node< T > *  right 
)

Definition at line 338 of file binary_tree.tpp.

◆ operator=() [1/2]

template<typename T >
BinaryTree< T > & stl_ext::BinaryTree< T >::operator= ( BinaryTree< T > &&  other)
noexcept

Definition at line 141 of file binary_tree.tpp.

◆ operator=() [2/2]

template<typename T >
BinaryTree< T > & stl_ext::BinaryTree< T >::operator= ( const BinaryTree< T > &  other)

Definition at line 124 of file binary_tree.tpp.

◆ postorder()

template<typename T >
void stl_ext::BinaryTree< T >::postorder ( const Node< T > *  node) const
protected

Definition at line 193 of file binary_tree.tpp.

◆ preorder()

template<typename T >
void stl_ext::BinaryTree< T >::preorder ( const Node< T > *  node) const
protected

Definition at line 157 of file binary_tree.tpp.

◆ print_inorder()

template<typename T >
void stl_ext::BinaryTree< T >::print_inorder ( ) const

Definition at line 317 of file binary_tree.tpp.

◆ print_levelorder()

template<typename T >
void stl_ext::BinaryTree< T >::print_levelorder ( ) const

Definition at line 327 of file binary_tree.tpp.

◆ print_postorder()

template<typename T >
void stl_ext::BinaryTree< T >::print_postorder ( ) const

Definition at line 322 of file binary_tree.tpp.

◆ print_preorder()

template<typename T >
void stl_ext::BinaryTree< T >::print_preorder ( ) const

Definition at line 312 of file binary_tree.tpp.

◆ print_tree()

template<typename T >
void stl_ext::BinaryTree< T >::print_tree ( ) const

Definition at line 356 of file binary_tree.tpp.

◆ print_tree_helper()

template<typename T >
void stl_ext::BinaryTree< T >::print_tree_helper ( const Node< T > *  node,
const std::string &  prefix,
bool  is_left 
) const
protected

Definition at line 344 of file binary_tree.tpp.

◆ set_left()

template<typename T >
void stl_ext::BinaryTree< T >::set_left ( Node< T > *  parent,
Node< T > *  left_child 
)

Definition at line 284 of file binary_tree.tpp.

◆ set_right()

template<typename T >
void stl_ext::BinaryTree< T >::set_right ( Node< T > *  parent,
Node< T > *  right_child 
)

Definition at line 298 of file binary_tree.tpp.

◆ set_root()

template<typename T >
void stl_ext::BinaryTree< T >::set_root ( Node< T > *  root)

Definition at line 265 of file binary_tree.tpp.

◆ size()

template<typename T >
int stl_ext::BinaryTree< T >::size ( ) const

Definition at line 279 of file binary_tree.tpp.

Member Data Documentation

◆ m_pool

template<typename T >
NodePool<T> stl_ext::BinaryTree< T >::m_pool
protected

Definition at line 97 of file cppx.h.

◆ p_head

template<typename T >
Node<T>* stl_ext::BinaryTree< T >::p_head = nullptr
protected

Definition at line 96 of file cppx.h.


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