ORIGINAL
|
Iterator for the array class that supports random access. More...
#include <array.h>
Public Member Functions | |
Iterator (const Iterator &other) | |
Copy constructor for the iterator. | |
Iterator & | operator= (const Iterator &other) |
Copy assignment operator for the iterator. | |
Iterator * | clone () const override |
Clones the iterator. | |
bool | atPrev (const iterator< TYPE > *other) const override |
Checks if this iterator is positioned just before the given iterator. | |
bool | atNext (const iterator< TYPE > *other) const override |
Checks if this iterator is positioned just after the given iterator. | |
std::string | className () const override |
Returns the class name of this iterator. | |
![]() | |
randomAccessIterator (const randomAccessIterator &other) | |
Copy constructor. | |
randomAccessIterator & | operator= (const randomAccessIterator &other) |
Copy assignment operator. | |
randomAccessIterator * | clone () const override |
Creates a heap-allocated copy. | |
bool | hasNext () const override |
Checks forward traversal capability. | |
bool | hasPrev () const override |
Checks reverse traversal capability. | |
bool | atPrev (const iterator< TYPE > *other) const override |
Checks if the current iterator is at the previous position compared to another iterator. | |
bool | atNext (const iterator< TYPE > *other) const override |
Checks if the current iterator is at the next position compared 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 N positions. | |
void | operator-= (integer steps) const override |
Moves backward by N positions. | |
integer | operator- (const iterator< TYPE > &other) const override |
Computes the distance between the current iterator and another iterator. | |
randomAccessIterator * | getNext () const override |
Gets an iterator pointing to the next element. | |
randomAccessIterator * | getPrev () const override |
Gets an iterator pointing to the previous element. | |
TYPE & | get () override |
Gets the current element in the container. | |
TYPE | get () const override |
Gets the current element in the container (const version) | |
void | set (const TYPE &data) override |
Sets the value of the current element. | |
bool | isValid () const override |
Checks if the iterator is valid (points to a valid element in the container) | |
std::string | className () const override |
Gets the class name of the iterator. | |
![]() | |
~baseIterator () override=default | |
Virtual destructor for proper cleanup of derived objects. | |
![]() | |
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. | |
![]() | |
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. | |
Public Attributes | |
friend | array |
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 |
![]() | |
randomAccessIterator (TYPE *ptr, const container< TYPE, ALLOC > *container, integer pos) | |
Protected constructor for derived classes. | |
bool | equalPtr (const iterator< TYPE > *other) const override |
Equality comparison implementation. | |
![]() | |
cloneable ()=default | |
Default constructor for cloneable. | |
![]() | |
baseCloneable ()=default | |
Default constructor for baseCloneable. | |
![]() | |
TYPE * | _ptr |
Pointer to the current element. | |
const container< TYPE, ALLOC > * | _container |
Reference to the parent container. | |
integer | _pos |
Absolute position in the container. | |
Iterator for the array class that supports random access.
TYPE | The type of elements stored in the array. |
ALLOC | The allocator type used by the parent array. |
The Iterator
class provides random access to the elements of an array
. It supports operations like operator++
, operator--
, and comparisons to iterate through the array elements in a bidirectional manner. The iterator is aware of the parent array's allocator through the base randomAccessIterator class.
original::array< TYPE, ALLOC >::Iterator::Iterator | ( | const Iterator & | other | ) |
Copy constructor for the iterator.
other | The iterator to copy. |
This constructor copies the state of the given iterator.
|
overridevirtual |
Checks if this iterator is positioned just after the given iterator.
other | The iterator to compare with. |
true
if this iterator is just after the other
iterator, false
otherwise.This method is used to compare the relative positions of two iterators.
Implements original::iterator< TYPE >.
|
overridevirtual |
Checks if this iterator is positioned just before the given iterator.
other | The iterator to compare with. |
true
if this iterator is just before the other
iterator, false
otherwise.This method is used to compare the relative positions of two iterators.
Implements original::iterator< TYPE >.
|
nodiscardoverridevirtual |
Returns the class name of this iterator.
Reimplemented from original::printable.
|
overridevirtual |
Clones the iterator.
The cloned iterator will point to the same position as the current iterator.
Implements original::baseIterator< TYPE >.
auto original::array< TYPE, ALLOC >::Iterator::operator= | ( | const Iterator & | other | ) |
Copy assignment operator for the iterator.
other | The iterator to copy from. |
This operator copies the state of the given iterator.