-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstDoublyLinkedListIterator.h
More file actions
110 lines (76 loc) · 2.91 KB
/
ConstDoublyLinkedListIterator.h
File metadata and controls
110 lines (76 loc) · 2.91 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
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
104
105
106
107
108
109
110
//
// Created by mfbut on 11/24/2019.
//
#ifndef DLLPROJECT_CONSTDOUBLYLINKEDLISTITERATOR_H
#define DLLPROJECT_CONSTDOUBLYLINKEDLISTITERATOR_H
#include <iterator>
#include "DoublyLinkedNode.h"
#include "DoublyLinkedListOutOfBoundsError.h"
template<typename T>
class ConstDoublyLinkedListIterator {
public:
//type tags
using iterator_category = std::bidirectional_iterator_tag;
using value_type = T;
using reference = const value_type&;
using pointer = const value_type*;
using difference_type = ptrdiff_t;
//create an iterator starting at the specified node
explicit ConstDoublyLinkedListIterator(const DoublyLinkedNode<T>* start);
//set the iterator to be at null
ConstDoublyLinkedListIterator();
//copy constructor
ConstDoublyLinkedListIterator(const ConstDoublyLinkedListIterator<T>& orig);
//are the two iterators equal?
bool operator==(const ConstDoublyLinkedListIterator<T>& rhs) const;
//are the two iterators different?
bool operator!=(const ConstDoublyLinkedListIterator<T>& rhs) const;
//is the iterator safe to dereference?
explicit operator bool() const;
//go to the next element
ConstDoublyLinkedListIterator<T>& operator++(); //pre
const ConstDoublyLinkedListIterator<T> operator++(int);//post
//go to the previous element
ConstDoublyLinkedListIterator<T>& operator--(); //pre
const ConstDoublyLinkedListIterator<T> operator--(int); //post
//get a reference to the value
reference operator*() const;
private:
const DoublyLinkedNode<T>* curNode;
};
template<typename T>
ConstDoublyLinkedListIterator<T>::ConstDoublyLinkedListIterator(const DoublyLinkedNode<T>* start) : curNode(start) {
}
template<typename T>
ConstDoublyLinkedListIterator<T>::ConstDoublyLinkedListIterator() : curNode(nullptr) {
}
template<typename T>
ConstDoublyLinkedListIterator<T>::ConstDoublyLinkedListIterator(const ConstDoublyLinkedListIterator<T>& orig) : curNode(orig.curNode) {
}
template<typename T>
bool ConstDoublyLinkedListIterator<T>::operator==(const ConstDoublyLinkedListIterator<T>& rhs) const {
return curNode == rhs.curNode;
}
template<typename T>
bool ConstDoublyLinkedListIterator<T>::operator!=(const ConstDoublyLinkedListIterator<T>& rhs) const {
return !(*this == rhs.curNode);
}
template<typename T>
ConstDoublyLinkedListIterator<T>::operator bool() const {
}
template<typename T>
ConstDoublyLinkedListIterator<T>& ConstDoublyLinkedListIterator<T>::operator++() {
}
template<typename T>
const ConstDoublyLinkedListIterator<T> ConstDoublyLinkedListIterator<T>::operator++(int) {
}
template<typename T>
ConstDoublyLinkedListIterator<T>& ConstDoublyLinkedListIterator<T>::operator--() {
}
template<typename T>
const ConstDoublyLinkedListIterator<T> ConstDoublyLinkedListIterator<T>::operator--(int) {
}
template<typename T>
typename ConstDoublyLinkedListIterator<T>::reference ConstDoublyLinkedListIterator<T>::operator*() const {
}
#endif //DLLPROJECT_CONSTDOUBLYLINKEDLISTITERATOR_H