-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.h
68 lines (55 loc) · 1.18 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
#ifndef EASYTRIP_NODE_H
#define EASYTRIP_NODE_H
template<class T>
class Node {
private:
T data;
int priority;
Node<T> *next;
public:
// Constructor
Node(T data, int priority);
Node(T data);
// Setter methods
void setData(T data);
void setPriority(int priority);
void setNext(Node<T> *next);
// Getter methods
T getData() const;
Node<T> *getNext() const;
int getPriority() const;
};
// Constructor
template<class T>
Node<T>::Node(T data) : data(data), next(nullptr) {}
template<class T>
Node<T>::Node(T data, int priority) : data(data), priority(priority), next(nullptr) {}
// Setter for data
template<class T>
void Node<T>::setData(T data) {
this->data = data;
}
template<class T>
void Node<T>::setPriority(int priority) {
this->priority = priority;
}
// Setter for next
template<class T>
void Node<T>::setNext(Node<T> *next) {
this->next = next;
}
// Getter for data
template<class T>
T Node<T>::getData() const {
return data;
}
// Getter for next
template<class T>
Node<T> *Node<T>::getNext() const {
return next;
}
template<class T>
int Node<T>::getPriority() const {
return priority;
}
#endif //EASYTRIP_NODE_H