ORIGINAL
|
Base iterator interface that supports common operations for iteration. More...
#include <iterator.h>
Public Member Functions | |
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). | |
virtual void | operator+= (integer steps) const =0 |
Adds a number of steps to the current position of iterator. | |
virtual void | operator-= (integer steps) const =0 |
Subtracts a number of steps from the current position of iterator. | |
integer | compareTo (const iterator &other) const override |
Compares two iterators to determine their relative positions. | |
virtual integer | operator- (const iterator &other) const =0 |
Returns the distance between this iterator and another iterator. | |
iterator * | clone () const override=0 |
Creates a clone of the iterator. | |
operator bool () const | |
Checks if the iterator is valid (i.e., points to a valid element). | |
virtual bool | hasNext () const =0 |
Checks if there is a next element. | |
virtual bool | hasPrev () const =0 |
Checks if there is a previous element. | |
virtual bool | atPrev (const iterator *other) const =0 |
Checks if this iterator is positioned at the previous element. | |
virtual bool | atNext (const iterator *other) const =0 |
Checks if this iterator is positioned at the next 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 void | next () const =0 |
Moves the iterator to the next element. | |
virtual void | prev () const =0 |
Moves the iterator to the previous element. | |
virtual iterator * | getNext () const |
Returns a new iterator pointing to the next element. | |
virtual iterator * | getPrev () const =0 |
Returns a new iterator pointing to the previous element. | |
virtual TYPE & | get ()=0 |
Gets the element pointed to by the iterator. | |
virtual TYPE | get () const =0 |
Gets a copy of the element pointed to by the iterator. | |
virtual TYPE | getElem () const |
Returns a copy of the element. | |
virtual void | set (const TYPE &data)=0 |
Sets the element pointed to by the iterator. | |
bool | equal (const iterator *other) const |
Checks if two iterators are equal. | |
bool | equal (const iterator &other) const |
Checks if two iterators are equal. | |
virtual bool | isValid () const =0 |
Checks if the iterator is valid. | |
std::string | className () const override |
Returns the class name of the iterator. | |
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. | |
![]() | |
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 |
![]() | |
~cloneable () override=default | |
Virtual destructor for cloneable. | |
![]() | |
virtual | ~baseCloneable ()=default |
Virtual destructor for baseCloneable. | |
![]() | |
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 | |
virtual bool | equalPtr (const iterator *other) const =0 |
Checks if two iterators point to the same object. | |
![]() | |
cloneable ()=default | |
Default constructor for cloneable. | |
![]() | |
baseCloneable ()=default | |
Default constructor for baseCloneable. | |
Friends | |
template<typename T> | |
iterator< T > * | operator+ (const iterator< T > &it, integer steps) |
Adds a number of steps to the iterator's current position and returns a new iterator. | |
template<typename T> | |
iterator< T > * | operator- (const iterator< T > &it, integer steps) |
Subtracts a number of steps from the iterator's current position and returns a new iterator. | |
Additional Inherited Members | |
![]() | |
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 |
Base iterator interface that supports common operations for iteration.
TYPE | The type of elements the iterator traverses. |
This class provides common operations for iterators, including dereferencing, moving forward and backward, and comparing iterators. It also supports cloning, and printing elements.
Derived classes are expected to provide specific implementations for methods like next()
, prev()
, get()
, and set()
. These implementations define the behavior of the iterator in a particular container.
Implements comparison based on a custom compareTo
method which compares iterators by the distance between them.
auto original::iterator< TYPE >::atNext | ( | const iterator< TYPE > & | other | ) | const |
Checks if this iterator is positioned at the next element.
other | The iterator to compare with. |
|
pure virtual |
Checks if this iterator is positioned at the next element.
other | The iterator to compare with. |
Implemented in original::array< TYPE, ALLOC >::Iterator, original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::chain< TYPE, ALLOC >::Iterator, original::forwardChain< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, original::stepIterator< TYPE >, and original::vector< TYPE, ALLOC >::Iterator.
auto original::iterator< TYPE >::atPrev | ( | const iterator< TYPE > & | other | ) | const |
Checks if this iterator is positioned at the previous element.
other | The iterator to compare with. |
|
pure virtual |
Checks if this iterator is positioned at the previous element.
other | The iterator to compare with. |
Implemented in original::array< TYPE, ALLOC >::Iterator, original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::chain< TYPE, ALLOC >::Iterator, original::forwardChain< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, original::stepIterator< TYPE >, and original::vector< TYPE, ALLOC >::Iterator.
|
nodiscardoverridevirtual |
Returns the class name of the iterator.
Reimplemented from original::printable.
Reimplemented in original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
overridepure virtual |
Creates a clone of the iterator.
Reimplemented from original::baseCloneable< cloneable >.
Implemented in original::array< TYPE, ALLOC >::Iterator, original::baseIterator< TYPE >, original::baseIterator< bool >, original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::chain< TYPE, ALLOC >::Iterator, original::doubleDirectionIterator< TYPE >, original::forwardChain< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, original::singleDirectionIterator< TYPE >, original::stepIterator< TYPE >, and original::vector< TYPE, ALLOC >::Iterator.
|
overridevirtual |
Compares two iterators to determine their relative positions.
other | The iterator to compare with. |
Implements original::comparable< iterator< TYPE > >.
auto original::iterator< TYPE >::equal | ( | const iterator< TYPE > & | other | ) | const |
Checks if two iterators are equal.
other | The iterator to compare with. |
auto original::iterator< TYPE >::equal | ( | const iterator< TYPE > * | other | ) | const |
Checks if two iterators are equal.
other | The iterator to compare with. |
|
protectedpure virtual |
Checks if two iterators point to the same object.
other | The iterator to compare with. |
Implemented in original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
pure virtual |
Gets a copy of the element pointed to by the iterator.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
pure virtual |
Gets the element pointed to by the iterator.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
virtual |
Returns a copy of the element.
|
virtual |
Returns a new iterator pointing to the next element.
Reimplemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
pure virtual |
Returns a new iterator pointing to the previous element.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
nodiscardpure virtual |
Checks if there is a next element.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
nodiscardpure virtual |
Checks if there is a previous element.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::doubleDirectionIterator< TYPE >, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
nodiscardpure virtual |
Checks if the iterator is valid.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
pure virtual |
Moves the iterator to the next element.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
explicit |
Checks if the iterator is valid (i.e., points to a valid element).
auto original::iterator< TYPE >::operator* | ( | ) |
Dereferences the iterator to get the element.
auto original::iterator< TYPE >::operator* | ( | ) | const |
Dereferences the iterator to get a copy of the element.
auto original::iterator< TYPE >::operator++ | ( | int | postfix | ) | const |
Moves the iterator forward by one position (postfix).
postfix | Unused parameter for postfix syntax. |
|
pure virtual |
Adds a number of steps to the current position of iterator.
steps | The number of steps to move forward. |
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
pure virtual |
Returns the distance between this iterator and another iterator.
other | The iterator to compare against. |
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
auto original::iterator< TYPE >::operator-- | ( | int | postfix | ) | const |
Moves the iterator backward by one position (postfix).
postfix | Unused parameter for postfix syntax. |
|
pure virtual |
Subtracts a number of steps from the current position of iterator.
steps | The number of steps to move backward. |
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
pure virtual |
Moves the iterator to the previous element.
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::doubleDirectionIterator< TYPE >, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
pure virtual |
Sets the element pointed to by the iterator.
data | The new value to set. |
Implemented in original::bitSet< ALLOC >::Iterator, original::blocksList< TYPE, ALLOC >::Iterator, original::iterable< TYPE >::iterAdaptor, original::randomAccessIterator< TYPE, ALLOC >, and original::stepIterator< TYPE >.
|
nodiscardoverridevirtual |
Returns a string representation of the iterator.
enter | If true, adds a newline after the string. |
Reimplemented from original::printable.
|
friend |
Adds a number of steps to the iterator's current position and returns a new iterator.
T | The type of the elements the iterator will traverse. |
it | The iterator to move. |
steps | The number of steps to move forward. |
This operator does not modify the original iterator, but creates a new one that is advanced by steps
positions.
|
friend |
Subtracts a number of steps from the iterator's current position and returns a new iterator.
T | The type of the elements the iterator will traverse. |
it | The iterator to move. |
steps | The number of steps to move backward. |
This operator does not modify the original iterator, but creates a new one that is moved backward by steps
positions.