35 template<
typename TYPE>
86 [[nodiscard]]
bool hasNext()
const override;
92 [[nodiscard]]
bool hasPrev()
const override;
111 void next()
const override;
117 void prev()
const override;
155 TYPE&
get()
override;
161 TYPE
get()
const override;
167 void set(
const TYPE& data)
override;
173 [[nodiscard]]
bool isValid()
const override;
179 [[nodiscard]] std::string
className()
const override;
183 template <
typename TYPE>
187 template <
typename TYPE>
190 auto* s = start->clone();
191 auto* e = end->clone();
193 while (s->isValid()){
194 if (s->_ptr == e->_ptr){
203 dis = std::numeric_limits<integer>::max();
210 template<
typename TYPE>
212 auto* other_it =
dynamic_cast<const stepIterator*
>(other);
213 return other_it !=
nullptr &&
_ptr == other_it->_ptr;
216 template <
typename TYPE>
223 template <
typename TYPE>
227 if (
this == &other) {
230 this->
_ptr = other._ptr;
234 template<
typename TYPE>
239 template <
typename TYPE>
245 template<
typename TYPE>
250 template <
typename TYPE>
256 template <
typename TYPE>
262 template <
typename TYPE>
266 this->
_ptr = this->
_ptr->getPNext();
269 template<
typename TYPE>
274 template <
typename TYPE>
282 for (
integer i = 0; i < steps; i++)
288 template <
typename TYPE>
296 for (
integer i = 0; i < steps; i++)
302 template <
typename TYPE>
305 auto* other_it =
dynamic_cast<const stepIterator*
>(&other);
306 if (other_it ==
nullptr)
307 return this > &other ?
308 std::numeric_limits<integer>::max() :
309 std::numeric_limits<integer>::min();
311 pos_dis != std::numeric_limits<integer>::max())
return pos_dis;
313 neg_dis != std::numeric_limits<integer>::max())
return -neg_dis;
314 return this->
_ptr > other_it->_ptr ?
315 std::numeric_limits<integer>::max() :
316 std::numeric_limits<integer>::min();
319 template <
typename TYPE>
324 template<
typename TYPE>
329 template <
typename TYPE>
333 return this->
_ptr->getVal();
336 template <
typename TYPE>
340 return this->
_ptr->getVal();
343 template <
typename TYPE>
347 this->
_ptr->setVal(data);
350 template <
typename TYPE>
353 return this->
_ptr !=
nullptr;
356 template <
typename TYPE>
359 return "stepIterator";
A base class for basic iterators.
Definition iterator.h:259
Base iterator interface that supports common operations for iteration.
Definition iterator.h:35
Exception for null pointer dereference attempts.
Definition error.h:110
iterator< TYPE > * getPrev() const override
Creates a new iterator pointing to the previous element.
Definition stepIterator.h:325
wrapper< TYPE > * _ptr
Pointer to the current wrapper.
Definition stepIterator.h:39
stepIterator * clone() const override
Creates a heap-allocated copy of the iterator.
Definition stepIterator.h:235
bool hasPrev() const override
Checks if the iterator can move backward.
Definition stepIterator.h:246
void set(const TYPE &data) override
Sets the value of the current element.
Definition stepIterator.h:344
bool equalPtr(const iterator< TYPE > *other) const override
Equality comparison for two iterators.
Definition stepIterator.h:211
integer operator-(const iterator< TYPE > &other) const override
Calculates the number of steps between the current iterator and another iterator.
Definition stepIterator.h:303
void next() const override
Advances to the next position in the container.
Definition stepIterator.h:263
std::string className() const override
Returns the class name of the iterator.
Definition stepIterator.h:357
TYPE & get() override
Gets the reference of current element in the container.
Definition stepIterator.h:330
void prev() const override
Retreats to the previous position in the container.
Definition stepIterator.h:270
stepIterator(wrapper< TYPE > *ptr)
Protected constructor for derived classes.
Definition stepIterator.h:184
bool atNext(const iterator< TYPE > *other) const override
Checks if the current iterator is at the next position relative to another iterator.
Definition stepIterator.h:257
bool hasNext() const override
Checks if the iterator can move forward.
Definition stepIterator.h:240
static integer ptrDistance(const stepIterator *start, const stepIterator *end)
Calculates the distance between two iterators.
Definition stepIterator.h:188
stepIterator & operator=(const stepIterator &other)
Copy assignment operator for stepIterator.
Definition stepIterator.h:224
void operator+=(integer steps) const override
Moves forward by a specified number of steps.
Definition stepIterator.h:275
bool isValid() const override
Checks if the iterator is valid.
Definition stepIterator.h:351
stepIterator * getNext() const override
Creates a new iterator pointing to the next element.
Definition stepIterator.h:320
bool atPrev(const iterator< TYPE > *other) const override
Checks if the current iterator is at the previous position relative to another iterator.
Definition stepIterator.h:251
void operator-=(integer steps) const override
Moves backward by a specified number of steps.
Definition stepIterator.h:289
Exception for unimplemented method calls.
Definition error.h:123
Base class for linked value containers with formatted output.
Definition wrapper.h:28
Custom exception classes and callback validation utilities.
Defines the iterator class for traversing and manipulating container elements.
Mathematical utilities and constants.
Main namespace for the project Original.
Definition algorithms.h:21
TYPE abs(TYPE a)
Returns the absolute value of a given number.
std::int64_t integer
64-bit signed integer type for arithmetic operations
Definition config.h:15
Abstract polymorphic container with value encapsulation and navigation support.