CPPX 1.1.2
A Modern C++ Utility Library
Loading...
Searching...
No Matches
node.tpp
Go to the documentation of this file.
1namespace stl_ext
2{
3
4template <typename T> Node<T>::Node(const Node &other) : m_data(other.m_data), m_height(other.m_height)
5{
6 if (other.p_left)
7 p_left = std::make_unique<Node<T>>(*other.p_left);
8 if (other.p_right)
9 p_right = std::make_unique<Node<T>>(*other.p_right);
10}
11
12template <typename T> Node<T> &Node<T>::operator=(const Node<T> &other)
13{
14 if (this == &other)
15 return *this;
16 m_data = other.m_data;
17 m_height = other.m_height;
18
19 p_left = other.p_left ? std::make_unique<Node<T>>(*other.p_left) : nullptr;
20 p_right = other.p_right ? std::make_unique<Node<T>>(*other.p_right) : nullptr;
21
22 return *this;
23}
24
25template <typename T> inline int Node<T>::get_height_val() const
26{
27 return m_height;
28}
29
30template <typename T> inline void Node<T>::set_height_val(int h)
31{
32 m_height = h;
33}
34
35template <typename T> inline std::unique_ptr<Node<T>> Node<T>::detach_left()
36{
37 return std::move(p_left);
38}
39
40template <typename T> inline std::unique_ptr<Node<T>> Node<T>::detach_right()
41{
42 return std::move(p_right);
43}
44
45template <typename T> const T &Node<T>::get_data() const
46{
47 return m_data;
48}
49
50template <typename T> void Node<T>::set_data(const T &val)
51{
52 m_data = val;
53}
54
55template <typename T> Node<T> *Node<T>::get_left() const
56{
57 return p_left.get();
58}
59
60template <typename T> void Node<T>::set_left(std::unique_ptr<Node<T>> node)
61{
62 p_left = std::move(node);
63}
64
65template <typename T> Node<T> *Node<T>::get_right() const
66{
67 return p_right.get();
68}
69
70template <typename T> void Node<T>::set_right(std::unique_ptr<Node<T>> node)
71{
72 p_right = std::move(node);
73}
74
75} // namespace stl_ext
std::unique_ptr< Node< T > > detach_left()
Definition node.tpp:35
int get_height_val() const
Definition node.tpp:25
Node(T val)
Definition cppx.h:28
void set_left(std::unique_ptr< Node< T > > node)
Definition node.tpp:60
std::unique_ptr< Node< T > > detach_right()
Definition node.tpp:40
Node & operator=(const Node &other)
Definition node.tpp:12
const T & get_data() const
Definition node.tpp:45
Node< T > * get_right() const
Definition node.tpp:65
void set_right(std::unique_ptr< Node< T > > node)
Definition node.tpp:70
Node< T > * get_left() const
Definition node.tpp:55
void set_data(const T &val)
Definition node.tpp:50
void set_height_val(int h)
Definition node.tpp:30
Definition cppx.h:12