ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator Class Referencefinal

Bidirectional iterator for hashMap. More...

#include <maps.h>

Inheritance diagram for original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator:
Inheritance graph
Collaboration diagram for original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator:
Collaboration graph

Public Member Functions

 Iterator (const Iterator &other)
 Copy constructor.
 
Iterator & operator= (const Iterator &other)
 Copy assignment operator.
 
Iterator * clone () const override
 Creates a copy of this iterator.
 
std::string className () const override
 Gets iterator class name.
 
void operator+= (integer steps) const override
 Advances iterator by steps.
 
void operator-= (integer steps) const override
 Not supported.
 
integer operator- (const iterator< couple< const K_TYPE, V_TYPE > > &other) const override
 Not supported.
 
bool hasNext () const override
 Checks if more elements exist.
 
bool hasPrev () const override
 Not supported.
 
bool atPrev (const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
 Checks if other is previous to this.
 
bool atNext (const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
 Checks if other is next to this.
 
void next () const override
 Moves to next element.
 
void prev () const override
 Not supported.
 
Iterator * getPrev () const override
 Not supported.
 
couple< const K_TYPE, V_TYPE > & get () override
 Gets current element (non-const)
 
couple< const K_TYPE, V_TYPE > get () const override
 Gets current element (const)
 
void set (const couple< const K_TYPE, V_TYPE > &data) override
 Not supported.
 
bool isValid () const override
 Checks if iterator is valid.
 
- Public Member Functions inherited from original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator
bool hasNext () const
 Checks if more elements are available.
 
void next () const
 Advances to the next element.
 
void operator+= (integer steps) const
 Advances iterator by steps positions.
 
couple< const K_TYPE, V_TYPE > & get ()
 Gets current key-value pair (non-const)
 
couple< const K_TYPE, V_TYPE > get () const
 Gets current key-value pair (const)
 
bool isValid () const
 Checks if iterator points to valid element.
 
- Public Member Functions inherited from original::baseIterator< couple< const K_TYPE, V_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.
 
virtual integer operator- (const iterator &other) const =0
 Returns the distance between this iterator and another iterator.
 
 operator bool () const
 Checks if the iterator is valid (i.e., points to a valid 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 iterator * getNext () const
 Returns a new iterator pointing to the next element.
 
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.
 
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.
 
- 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.
 

Friends

class hashMap
 

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
 
- Protected Member Functions inherited from original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator
 Iterator (vector< hashNode *, rebind_alloc_pointer > *buckets=nullptr, u_integer bucket=0, hashNode *node=nullptr)
 Constructs an iterator pointing to specific position.
 
 Iterator (const Iterator &other)
 Copy constructor.
 
Iterator & operator= (const Iterator &other)
 Copy assignment operator.
 
- Protected Member Functions inherited from original::iterator< TYPE >
virtual bool equalPtr (const iterator *other) const =0
 Checks if two iterators point to the same underlying element.
 
- 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 inherited from original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator
static u_integer findNextValidBucket (vector< hashNode *, rebind_alloc_pointer > *buckets, u_integer bucket)
 Finds the next non-empty bucket.
 
static u_integer findPrevValidBucket (vector< hashNode *, rebind_alloc_pointer > *buckets, u_integer bucket)
 Finds the previous non-empty bucket.
 
- Protected Attributes inherited from original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator
vector< hashNode *, rebind_alloc_pointer > * p_buckets
 
u_integer cur_bucket
 
hashNode * p_node
 

Detailed Description

template<typename K_TYPE, typename V_TYPE, typename HASH = hash<K_TYPE>, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
class original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator

Bidirectional iterator for hashMap.

Provides iteration over hashMap elements while maintaining:

Iterator Characteristics:

Constructor & Destructor Documentation

◆ Iterator()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::Iterator ( const Iterator &  other)

Copy constructor.

Parameters
otherIterator to copy

Member Function Documentation

◆ atNext()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
bool original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::atNext ( const iterator< couple< const K_TYPE, V_TYPE > > *  other) const
override

Checks if other is next to this.

Parameters
otherIterator to check
Returns
true if other is next

◆ atPrev()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
bool original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::atPrev ( const iterator< couple< const K_TYPE, V_TYPE > > *  other) const
override

Checks if other is previous to this.

Parameters
otherIterator to check
Returns
true if other is previous

◆ className()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
std::string original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::className ( ) const
overridevirtual

Gets iterator class name.

Returns
"hashMap::Iterator"

Reimplemented from original::printable.

◆ clone()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator * original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::clone ( ) const
overridevirtual

Creates a copy of this iterator.

Returns
New iterator instance

Implements original::baseIterator< couple< const K_TYPE, V_TYPE > >.

◆ get() [1/2]

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
original::couple< const K_TYPE, V_TYPE > original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::get ( ) const
overridevirtual

Gets current element (const)

Returns
Copy of current key-value pair

Implements original::iterator< TYPE >.

◆ get() [2/2]

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
original::couple< const K_TYPE, V_TYPE > & original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::get ( )
overridevirtual

Gets current element (non-const)

Returns
Reference to current key-value pair

Implements original::iterator< TYPE >.

◆ getPrev()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator * original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::getPrev ( ) const
overridevirtual

Not supported.

Exceptions
unSupportedMethodError

Implements original::iterator< TYPE >.

◆ hasNext()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
bool original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::hasNext ( ) const
overridevirtual

Checks if more elements exist.

Returns
true if more elements available

Implements original::iterator< TYPE >.

◆ hasPrev()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
bool original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::hasPrev ( ) const
overridevirtual

Not supported.

Exceptions
unSupportedMethodError

Implements original::iterator< TYPE >.

◆ isValid()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
bool original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::isValid ( ) const
overridevirtual

Checks if iterator is valid.

Returns
true if iterator points to valid element

Implements original::iterator< TYPE >.

◆ next()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
void original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::next ( ) const
overridevirtual

Moves to next element.

Implements original::iterator< TYPE >.

◆ operator+=()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
void original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::operator+= ( integer  steps) const
overridevirtual

Advances iterator by steps.

Parameters
stepsNumber of positions to advance
Exceptions
unSupportedMethodErrorif steps is negative

Implements original::iterator< TYPE >.

◆ operator-()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
original::integer original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::operator- ( const iterator< couple< const K_TYPE, V_TYPE > > &  other) const
override

Not supported.

Exceptions
unSupportedMethodError

◆ operator-=()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
void original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::operator-= ( integer  steps) const
overridevirtual

Not supported.

Exceptions
unSupportedMethodError

Implements original::iterator< TYPE >.

◆ operator=()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator & original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::operator= ( const Iterator &  other)

Copy assignment operator.

Parameters
otherIterator to copy
Returns
Reference to this iterator

◆ prev()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
void original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::prev ( ) const
overridevirtual

Not supported.

Exceptions
unSupportedMethodError

Implements original::iterator< TYPE >.

◆ set()

template<typename K_TYPE , typename V_TYPE , typename HASH , typename ALLOC >
void original::hashMap< K_TYPE, V_TYPE, HASH, ALLOC >::Iterator::set ( const couple< const K_TYPE, V_TYPE > &  data)
override

Not supported.

Exceptions
unSupportedMethodError

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