-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.h
48 lines (38 loc) · 794 Bytes
/
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
//
// Created by abasiy on ۱۷/۱۱/۲۰۲۳.
//
#ifndef DATASTRUCTURE_NODE_H
#define DATASTRUCTURE_NODE_H
template <class T>
class Node{
private:
T data;
Node* next;
Node* pre;
public:
Node(T data, Node<T> *next = nullptr, Node<T> *before = nullptr) {
this->data = data;
this->next = next;
this->pre = before;
}
~Node(){
this->next = nullptr;
this->pre = nullptr;
}
Node* nextNode() const{
return this->next;
}
void setNextNode(Node<T> *node){
this->next = node;
}
T value() const{
return this->data;
}
Node<T>* preNode() const{
return this->pre;
}
void setPreNode(Node<T> *node){
this->pre = node;
}
};
#endif //DATASTRUCTURE_NODE_H