ORIGINAL
Loading...
Searching...
No Matches
original::stepIterator< TYPE > Class Template Reference

Abstract base class for step iterators. More...

#include <stepIterator.h>

Inheritance diagram for original::stepIterator< TYPE >:
Inheritance graph
Collaboration diagram for original::stepIterator< TYPE >:
Collaboration graph

Public Member Functions

 stepIterator (const stepIterator &other)
 Copy constructor for stepIterator.
 
stepIteratoroperator= (const stepIterator &other)
 Copy assignment operator for stepIterator.
 
stepIteratorclone () const override
 Creates a heap-allocated copy of the iterator.
 
bool hasNext () const override
 Checks if the iterator can move forward.
 
bool hasPrev () const override
 Checks if the iterator can move backward.
 
bool atPrev (const iterator< TYPE > *other) const override
 Checks if the current iterator is at the previous position relative to another iterator.
 
bool atNext (const iterator< TYPE > *other) const override
 Checks if the current iterator is at the next position relative to another iterator.
 
void next () const override
 Advances to the next position in the container.
 
void prev () const override
 Retreats to the previous position in the container.
 
void operator+= (integer steps) const override
 Moves forward by a specified number of steps.
 
void operator-= (integer steps) const override
 Moves backward by a specified number of steps.
 
integer operator- (const iterator< TYPE > &other) const override
 Calculates the number of steps between the current iterator and another iterator.
 
stepIteratorgetNext () const override
 Creates a new iterator pointing to the next element.
 
iterator< TYPE > * getPrev () const override
 Creates a new iterator pointing to the previous element.
 
TYPE & get () override
 Gets the reference of current element in the container.
 
TYPE get () const override
 Gets the current element in the container.
 
void set (const TYPE &data) override
 Sets the value of the current element.
 
bool isValid () const override
 Checks if the iterator is valid.
 
std::string className () const override
 Returns the class name of the iterator.
 
- Public Member Functions inherited from original::baseIterator< TYPE >
 ~baseIterator () override=default
 Virtual destructor for proper cleanup of derived objects.
 
- Public Member Functions inherited from original::iterator< TYPE >
TYPE & operator* ()
 Dereferences the iterator to get the element.
 
TYPE operator* () const
 Dereferences the iterator to get a copy of the element.
 
void operator++ () const
 Moves the iterator forward by one position.
 
void operator++ (int postfix) const
 Moves the iterator forward by one position (postfix).
 
void operator-- () const
 Moves the iterator backward by one position.
 
void operator-- (int postfix) const
 Moves the iterator backward by one position (postfix).
 
integer compareTo (const iterator &other) const override
 Compares two iterators to determine their relative positions.
 
 operator bool () const
 Checks if the iterator is valid (i.e., points to a valid element).
 
bool atPrev (const iterator &other) const
 Checks if this iterator is positioned at the previous element.
 
bool atNext (const iterator &other) const
 Checks if this iterator is positioned at the next element.
 
virtual TYPE getElem () const
 Returns a copy of the element.
 
bool equal (const iterator *other) const
 Checks if two iterators are equal.
 
bool equal (const iterator &other) const
 Checks if two iterators are equal.
 
std::string toString (bool enter) const override
 Returns a string representation of the iterator.
 
 ~iterator () override=default
 Virtual destructor for proper cleanup of derived objects.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const char * toCString (bool enter) const
 Direct C-string access with formatting control.
 
template<typename TYPE>
auto formatString (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatCString (const TYPE &t) -> const char *
 
template<typename TYPE>
auto formatEnum (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatString (TYPE *const &ptr) -> std::string
 
- Public Member Functions inherited from original::cloneable
 ~cloneable () override=default
 Virtual destructor for cloneable.
 
- Public Member Functions inherited from original::baseCloneable< cloneable >
virtual ~baseCloneable ()=default
 Virtual destructor for baseCloneable.
 
- Public Member Functions inherited from original::comparable< iterator< TYPE > >
bool operator== (const iterator< TYPE > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const iterator< TYPE > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const iterator< TYPE > &other) const
 Checks if the current object is less than another.
 
bool operator> (const iterator< TYPE > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const iterator< TYPE > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const iterator< TYPE > &other) const
 Checks if the current object is greater than or equal to another.
 
virtual ~comparable ()=default
 Virtual destructor for proper cleanup of derived objects.
 

Protected Member Functions

 stepIterator (wrapper< TYPE > *ptr)
 Protected constructor for derived classes.
 
bool equalPtr (const iterator< TYPE > *other) const override
 Equality comparison for two iterators.
 
- Protected Member Functions inherited from original::cloneable
 cloneable ()=default
 Default constructor for cloneable.
 
- Protected Member Functions inherited from original::baseCloneable< cloneable >
 baseCloneable ()=default
 Default constructor for baseCloneable.
 

Static Protected Member Functions

static integer ptrDistance (const stepIterator *start, const stepIterator *end)
 Calculates the distance between two iterators.
 

Protected Attributes

wrapper< TYPE > * _ptr
 Pointer to the current wrapper.
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
template<typename TYPE>
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion.
 
template<typename TYPE>
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting.
 
template<typename TYPE>
static const char * formatCString (const TYPE &t)
 C-string cache for temporary usage.
 
template<typename TYPE>
static std::string formatEnum (const TYPE &t)
 Enum formatting utility.
 
template<>
auto formatString (const char &t) -> std::string
 
template<>
auto formatString (const bool &t) -> std::string
 
template<>
auto formatString (const char *const &ptr) -> std::string
 

Detailed Description

template<typename TYPE>
class original::stepIterator< TYPE >

Abstract base class for step iterators.

Template Parameters
TYPEType of elements being iterated

Implements core functionality for iterators that iterate through elements one step at a time. Supports:

  • Stepwise forward traversal (next and prev)
  • Cloning and comparison operations
  • Element access/modification
  • Position validity checking
Note
Derived iterators should provide the specific behavior of moving to the next element and accessing the current element.

Constructor & Destructor Documentation

◆ stepIterator() [1/2]

template<typename TYPE>
original::stepIterator< TYPE >::stepIterator ( wrapper< TYPE > * ptr)
explicitprotected

Protected constructor for derived classes.

Parameters
ptrRaw pointer to the element

◆ stepIterator() [2/2]

template<typename TYPE>
original::stepIterator< TYPE >::stepIterator ( const stepIterator< TYPE > & other)

Copy constructor for stepIterator.

Parameters
otherThe iterator to copy

Member Function Documentation

◆ atNext()

template<typename TYPE>
auto original::stepIterator< TYPE >::atNext ( const iterator< TYPE > * other) const
overridevirtual

Checks if the current iterator is at the next position relative to another iterator.

Parameters
otherThe iterator to compare with
Returns
Always throws unSupportedMethodError for forward checks

Implements original::iterator< TYPE >.

◆ atPrev()

template<typename TYPE>
auto original::stepIterator< TYPE >::atPrev ( const iterator< TYPE > * other) const
overridevirtual

Checks if the current iterator is at the previous position relative to another iterator.

Parameters
otherThe iterator to compare with
Returns
Always throws unSupportedMethodError for backward checks

Implements original::iterator< TYPE >.

◆ className()

template<typename TYPE>
auto original::stepIterator< TYPE >::className ( ) const
nodiscardoverridevirtual

Returns the class name of the iterator.

Returns
The class name as a string

Reimplemented from original::iterator< TYPE >.

◆ clone()

template<typename TYPE>
auto original::stepIterator< TYPE >::clone ( ) const
overridevirtual

Creates a heap-allocated copy of the iterator.

Returns
A new heap-allocated stepIterator

Implements original::baseIterator< TYPE >.

◆ equalPtr()

template<typename TYPE>
auto original::stepIterator< TYPE >::equalPtr ( const iterator< TYPE > * other) const
overrideprotectedvirtual

Equality comparison for two iterators.

Parameters
otherIterator to compare with
Returns
True if the iterators point to the same element, otherwise false

Implements original::iterator< TYPE >.

◆ get() [1/2]

template<typename TYPE>
auto original::stepIterator< TYPE >::get ( ) const
overridevirtual

Gets the current element in the container.

Returns
A constant reference to the current element

Implements original::iterator< TYPE >.

◆ get() [2/2]

template<typename TYPE>
auto original::stepIterator< TYPE >::get ( )
overridevirtual

Gets the reference of current element in the container.

Returns
A reference to the current element

Implements original::iterator< TYPE >.

◆ getNext()

template<typename TYPE>
auto original::stepIterator< TYPE >::getNext ( ) const
overridevirtual

Creates a new iterator pointing to the next element.

Returns
A new stepIterator pointing to the next element

Reimplemented from original::iterator< TYPE >.

◆ getPrev()

template<typename TYPE>
auto original::stepIterator< TYPE >::getPrev ( ) const
overridevirtual

Creates a new iterator pointing to the previous element.

Returns
Always throws unSupportedMethodError for backward iteration

Implements original::iterator< TYPE >.

◆ hasNext()

template<typename TYPE>
auto original::stepIterator< TYPE >::hasNext ( ) const
nodiscardoverridevirtual

Checks if the iterator can move forward.

Returns
True if the iterator is not at the end, otherwise false

Implements original::iterator< TYPE >.

◆ hasPrev()

template<typename TYPE>
auto original::stepIterator< TYPE >::hasPrev ( ) const
nodiscardoverridevirtual

Checks if the iterator can move backward.

Returns
Always throws unSupportedMethodError since this iterator only supports forward movement

Implements original::iterator< TYPE >.

◆ isValid()

template<typename TYPE>
auto original::stepIterator< TYPE >::isValid ( ) const
nodiscardoverridevirtual

Checks if the iterator is valid.

Returns
True if the iterator is valid (points to a valid element), otherwise false

Implements original::iterator< TYPE >.

◆ next()

template<typename TYPE>
void original::stepIterator< TYPE >::next ( ) const
overridevirtual

Advances to the next position in the container.

Implements original::iterator< TYPE >.

◆ operator+=()

template<typename TYPE>
auto original::stepIterator< TYPE >::operator+= ( integer steps) const
overridevirtual

Moves forward by a specified number of steps.

Parameters
stepsThe number of positions to move forward

Implements original::iterator< TYPE >.

◆ operator-()

template<typename TYPE>
auto original::stepIterator< TYPE >::operator- ( const iterator< TYPE > & other) const
overridevirtual

Calculates the number of steps between the current iterator and another iterator.

Parameters
otherThe iterator to compare with
Returns
The number of steps between the two iterators

Implements original::iterator< TYPE >.

◆ operator-=()

template<typename TYPE>
auto original::stepIterator< TYPE >::operator-= ( integer steps) const
overridevirtual

Moves backward by a specified number of steps.

Parameters
stepsThe number of positions to move backward

This operation is supported by internally calling operator+= with a negative value of steps.

Implements original::iterator< TYPE >.

◆ operator=()

template<typename TYPE>
auto original::stepIterator< TYPE >::operator= ( const stepIterator< TYPE > & other)

Copy assignment operator for stepIterator.

Parameters
otherThe iterator to copy
Returns
Reference to this iterator

◆ prev()

template<typename TYPE>
auto original::stepIterator< TYPE >::prev ( ) const
overridevirtual

Retreats to the previous position in the container.

Always throws unSupportedMethodError since backward movement is not supported for step iterators.

Implements original::iterator< TYPE >.

◆ ptrDistance()

template<typename TYPE>
auto original::stepIterator< TYPE >::ptrDistance ( const stepIterator< TYPE > * start,
const stepIterator< TYPE > * end )
staticprotected

Calculates the distance between two iterators.

Parameters
startIterator pointing to the start position
endIterator pointing to the end position
Returns
The number of steps between the two iterators

◆ set()

template<typename TYPE>
auto original::stepIterator< TYPE >::set ( const TYPE & data)
overridevirtual

Sets the value of the current element.

Parameters
dataThe value to set to the current element

Implements original::iterator< TYPE >.


The documentation for this class was generated from the following file: