-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.h
103 lines (80 loc) · 1.42 KB
/
Node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef NODE_H
#define NODE_H
#include <cassert>
template<typename T>
class List;
template<typename T>
class Node
{
friend List<T>;
public:
Node(const Node & copy);
Node & operator =(const Node & rhs);
~Node();
Node * getNext()const;
void setNext(Node * next);
void SetPrev(Node * Prev);
Node * getPrev()const;
T getData()const;
private:
Node();
Node(T Data);
T m_Data;
Node * m_Next;
Node * m_Previous;
};
#endif
template<typename T>
inline Node<T>::Node():m_Next(nullptr), m_Previous(nullptr)
{
m
}
template<typename T>
inline Node<T>::Node(T Data):m_Data(Data)
{
}
template<typename T>
inline Node<T>::Node(const Node & copy)
{
*this = copy;
}
template<typename T>
inline Node<T> & Node<T>::operator=(const Node & rhs)
{
if (this != &rhs)
{
m_Data = rhs.m_Data;
}
return *this;
}
template<typename T>
inline Node<T>::~Node()
{
}
template<typename T>
inline Node<T> * Node<T>::getNext() const
{
return m_Next;
}
template<typename T>
inline void Node<T>::setNext(Node * next)
{
assert(next != nullptr);
m_Next = next;
}
template<typename T>
inline void Node<T>::SetPrev(Node * Prev)
{
assert(next != nullptr);
m_Previous = Prev;
}
template<typename T>
inline Node<T> * Node<T>::getPrev() const
{
return m_Previous;
}
template<typename T>
inline T Node<T>::getData() const
{
return m_Data;
}