12 template<
typename TYPE>
22 stepIterator(
const stepIterator& other);
23 stepIterator& operator=(
const stepIterator& other);
24 stepIterator* clone()
const override;
25 [[nodiscard]]
bool hasNext()
const override;
26 [[nodiscard]]
bool hasPrev()
const override;
29 void next()
const override;
30 void prev()
const override;
31 void operator+=(int64_t steps)
const override;
32 void operator-=(int64_t steps)
const override;
34 stepIterator* getNext()
const override;
37 TYPE get()
const override;
38 void set(
const TYPE& data)
override;
39 [[nodiscard]]
bool isValid()
const override;
40 [[nodiscard]] std::string className()
const override;
44 template <
typename TYPE>
45 original::stepIterator<TYPE>::stepIterator(wrapper<TYPE>* ptr)
48 template <
typename TYPE>
53 while (cur !=
nullptr)
59 cur = cur->getPNext();
62 return std::numeric_limits<int64_t>::max();
65 template<
typename TYPE>
66 auto original::stepIterator<TYPE>::equalPtr(
const iterator<TYPE> *other)
const ->
bool {
67 auto* other_it =
dynamic_cast<const stepIterator*
>(other);
68 return other_it !=
nullptr && _ptr == other_it->_ptr;
71 template <
typename TYPE>
72 original::stepIterator<TYPE>::stepIterator(
const stepIterator& other)
75 this->operator=(other);
78 template <
typename TYPE>
79 auto original::stepIterator<TYPE>::operator=(
85 this->_ptr = other._ptr;
89 template<
typename TYPE>
90 auto original::stepIterator<TYPE>::clone() const ->
stepIterator* {
94 template <
typename TYPE>
95 auto original::stepIterator<TYPE>::hasNext() const ->
bool
97 return this->isValid();
100 template<
typename TYPE>
101 auto original::stepIterator<TYPE>::hasPrev() const ->
bool {
105 template <
typename TYPE>
106 auto original::stepIterator<TYPE>::atPrev(
const iterator<TYPE>* other)
const ->
bool
111 template <
typename TYPE>
112 auto original::stepIterator<TYPE>::atNext(
const iterator<TYPE>* other)
const ->
bool
117 template <
typename TYPE>
118 void original::stepIterator<TYPE>::next()
const
121 this->_ptr = this->_ptr->getPNext();
124 template<
typename TYPE>
125 auto original::stepIterator<TYPE>::prev() const ->
void {
129 template <
typename TYPE>
130 auto original::stepIterator<TYPE>::operator+=(
const int64_t steps)
const ->
void
133 this->operator-=(abs(steps));
137 for (int64_t i = 0; i < steps; i++)
143 template <
typename TYPE>
144 auto original::stepIterator<TYPE>::operator-=(
const int64_t steps)
const ->
void
147 this->operator+=(abs(steps));
151 for (int64_t i = 0; i < steps; i++)
157 template <
typename TYPE>
158 auto original::stepIterator<TYPE>::operator-(
const iterator<TYPE>& other)
const -> int64_t
160 auto* other_it =
dynamic_cast<const stepIterator*
>(&other);
161 if (other_it ==
nullptr)
162 return this > &other ?
163 std::numeric_limits<int64_t>::max() :
164 std::numeric_limits<int64_t>::min();
165 if (
const int64_t pos_dis = ptrDistance(other_it->_ptr, this->_ptr);
166 pos_dis != std::numeric_limits<int64_t>::max())
return pos_dis;
167 if (
const int64_t neg_dis = ptrDistance(this->_ptr, other_it->_ptr);
168 neg_dis != std::numeric_limits<int64_t>::max())
return -neg_dis;
169 return this->_ptr > other_it->_ptr ?
170 std::numeric_limits<int64_t>::max() :
171 std::numeric_limits<int64_t>::min();
174 template <
typename TYPE>
175 auto original::stepIterator<TYPE>::getNext() const ->
stepIterator* {
179 template<
typename TYPE>
180 auto original::stepIterator<TYPE>::getPrev() const ->
iterator<TYPE>* {
184 template <
typename TYPE>
185 auto original::stepIterator<TYPE>::get() -> TYPE&
188 return this->_ptr->getVal();
191 template <
typename TYPE>
192 auto original::stepIterator<TYPE>::get() const -> TYPE
195 return this->_ptr->getVal();
198 template <
typename TYPE>
199 auto original::stepIterator<TYPE>::set(
const TYPE& data) ->
void
202 this->_ptr->setVal(data);
205 template <
typename TYPE>
206 auto original::stepIterator<TYPE>::isValid() const ->
bool
208 return this->_ptr !=
nullptr;
211 template <
typename TYPE>
212 auto original::stepIterator<TYPE>::className() const -> std::
string
214 return "stepIterator";
Definition stepIterator.h:14