ORIGINAL
Loading...
Searching...
No Matches
doubleDirectionIterator.h
1#ifndef DOUBLEDIRECTIONITERATOR_H
2#define DOUBLEDIRECTIONITERATOR_H
3#include "stepIterator.h"
4
5namespace original {
6 template<typename TYPE>
7 class doubleDirectionIterator : public stepIterator<TYPE> {
8 protected:
9 explicit doubleDirectionIterator(wrapper<TYPE>* ptr);
10 public:
11 doubleDirectionIterator(const doubleDirectionIterator& other);
12 doubleDirectionIterator& operator=(const doubleDirectionIterator& other);
13 doubleDirectionIterator* clone() const override;
14 [[nodiscard]] bool hasPrev() const override;
15 void prev() const override;
16 };
17}
18
19 template<typename TYPE>
20 original::doubleDirectionIterator<TYPE>::doubleDirectionIterator(wrapper<TYPE>* ptr)
21 : stepIterator<TYPE>(ptr) {}
22
23 template<typename TYPE>
24 original::doubleDirectionIterator<TYPE>::doubleDirectionIterator(const doubleDirectionIterator &other)
25 : stepIterator<TYPE>(nullptr) {
26 this->operator=(other);
27 }
28
29 template<typename TYPE>
30 original::doubleDirectionIterator<TYPE> & original::doubleDirectionIterator<TYPE>::operator=(
31 const doubleDirectionIterator &other) {
32 if (this == &other) {
33 return *this;
34 }
35 this->stepIterator<TYPE>::operator=(other);
36 return *this;
37 }
38
39 template<typename TYPE>
40 bool original::doubleDirectionIterator<TYPE>::hasPrev() const {
41 return this->isValid();
42 }
43
44 template<typename TYPE>
45 void original::doubleDirectionIterator<TYPE>::prev() const {
46 if (!this->isValid()) throw nullPointerError();
47 this->_ptr = this->_ptr->getPPrev();
48 }
49
50 template<typename TYPE>
51 auto original::doubleDirectionIterator<TYPE>::clone() const -> doubleDirectionIterator* {
52 return new doubleDirectionIterator(*this);
53 }
54
55#endif //DOUBLEDIRECTIONITERATOR_H
Definition doubleDirectionIterator.h:7
Definition error.h:28
Definition stepIterator.h:14
Definition wrapper.h:12