-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode_iterator.cpp
More file actions
47 lines (45 loc) · 1.34 KB
/
Copy pathNode_iterator.cpp
File metadata and controls
47 lines (45 loc) · 1.34 KB
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
//
// Created by jonng on 3/24/2021.
//
#ifndef TEMPLATED_LINKED_LIST_NODE_ITERATOR_CPP
#define TEMPLATED_LINKED_LIST_NODE_ITERATOR_CPP
#include "Node_iterator.h"
template <class T>
Node_iterator<T>& Node_iterator<T>::operator ++ () { //Prefix
current_node = current_node->next;
return *this;
}
template <class T>
Node_iterator<T> Node_iterator<T>::operator ++ (int) {
Node_iterator<T> temp = *this;
current_node = current_node->next;
return temp;
}
template <class T>
Node_iterator<T>& Node_iterator<T>::operator -- () {
current_node = current_node->prev;
return *this;
}
template <class T>
Node_iterator<T> Node_iterator<T>::operator -- (int) {
Node_iterator<T> temp = *this;
current_node = current_node->prev;
return temp;
}
template <class T>
T& Node_iterator<T>::operator *() const {
return current_node->data;
}
template <class T>
Node_iterator<T>::Node_iterator (Node<T>* n) : current_node(n){ }
template <class T>
Node_iterator<T>::Node_iterator () : Node_iterator(nullptr) {}
template <class S>
bool operator == (const Node_iterator<S>& LH, const Node_iterator<S>& RH) {
return (LH.current_node == RH.current_node);
}
template <class S>
bool operator != (const Node_iterator<S>& LH, const Node_iterator<S>& RH) {
return (LH.current_node != RH.current_node);
}
#endif //TEMPLATED_LINKED_LIST_NODE_ITERATOR_H