MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
BinaryTree< T > Class Template Reference

#include <binarytree.h>

Inheritance diagram for BinaryTree< T >:
[legend]

Public Member Functions

 BinaryTree ()
 
 BinaryTree (BinaryTreeNode< T > *root)
 
BinaryTreeNode< T > * getRoot ()
 
MInt getMaxDepth ()
 

Protected Member Functions

MInt getNodeDepth (BinaryTreeNode< T > *node)
 

Protected Attributes

BinaryTreeNode< T > * m_root
 

Detailed Description

template<typename T>
class BinaryTree< T >

Definition at line 60 of file binarytree.h.

Constructor & Destructor Documentation

◆ BinaryTree() [1/2]

template<typename T >
BinaryTree< T >::BinaryTree ( )
inline

Definition at line 54 of file binarytree.h.

62{ m_root = nullptr; }
BinaryTreeNode< T > * m_root
Definition: binarytree.h:82

◆ BinaryTree() [2/2]

template<typename T >
BinaryTree< T >::BinaryTree ( BinaryTreeNode< T > *  root)
inlineexplicit

Definition at line 54 of file binarytree.h.

63{ m_root = root; }

Member Function Documentation

◆ getMaxDepth()

template<typename T >
MInt BinaryTree< T >::getMaxDepth ( )
inline

Definition at line 67 of file binarytree.h.

67 {
68 if(m_root == nullptr) {
69 return 0;
70 }
71
72 MInt lDepth = getNodeDepth(m_root->getLeftChild());
73 MInt rDepth = getNodeDepth(m_root->getRightChild());
74
75 if(lDepth > rDepth) {
76 return (lDepth + 1);
77 }
78 return (rDepth + 1);
79 }
MInt getNodeDepth(BinaryTreeNode< T > *node)
Definition: binarytree.h:84
int32_t MInt
Definition: maiatypes.h:62

◆ getNodeDepth()

template<typename T >
MInt BinaryTree< T >::getNodeDepth ( BinaryTreeNode< T > *  node)
inlineprotected

Definition at line 84 of file binarytree.h.

84 {
85 if(node == nullptr) {
86 return (0);
87 }
88
89 MInt lDepth = getNodeDepth(m_root->getLeftChild());
90 MInt rDepth = getNodeDepth(m_root->getRightChild());
91
92 if(lDepth > rDepth) {
93 return (lDepth + 1);
94 }
95 return (rDepth + 1);
96 }

◆ getRoot()

template<typename T >
BinaryTreeNode< T > * BinaryTree< T >::getRoot ( )
inline

Definition at line 65 of file binarytree.h.

65{ return m_root; }

Member Data Documentation

◆ m_root

template<typename T >
BinaryTreeNode<T>* BinaryTree< T >::m_root
protected

Definition at line 82 of file binarytree.h.


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