ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator Class Reference

Forward iterator for hashTable. More...

#include <hashTable.h>

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

Public Member Functions

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_TYPEget () const
 Gets current key-value pair (const)
 
bool isValid () const
 Checks if iterator points to valid element.
 

Protected Member Functions

 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.
 
Iteratoroperator= (const Iterator &other)
 Copy assignment operator.
 

Static Protected Member Functions

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

vector< hashNode *, rebind_alloc_pointer > * p_buckets
 
u_integer cur_bucket
 
hashNodep_node
 

Detailed Description

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

Forward iterator for hashTable.

Provides forward iteration over hashTable elements with:

Iterator Characteristics:

Note
Iterators remain valid unless the table is rehashed

Constructor & Destructor Documentation

◆ Iterator() [1/2]

original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator::Iterator ( vector< hashNode *, rebind_alloc_pointer > *  buckets = nullptr,
u_integer  bucket = 0,
hashNode node = nullptr 
)
explicitprotected

Constructs an iterator pointing to specific position.

Parameters
bucketsPointer to buckets vector
bucketCurrent bucket index
nodeCurrent node pointer
Note
Protected constructor for use by hashTable only

◆ Iterator() [2/2]

original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator::Iterator ( const Iterator other)
protected

Copy constructor.

Parameters
otherIterator to copy

Member Function Documentation

◆ findNextValidBucket()

original::u_integer original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator::findNextValidBucket ( vector< hashNode *, rebind_alloc_pointer > *  buckets,
u_integer  bucket 
)
staticprotected

Finds the next non-empty bucket.

Parameters
bucketsReference to buckets vector
bucketStarting bucket index
Returns
Index of next non-empty bucket or buckets.size() if none

◆ findPrevValidBucket()

original::u_integer original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator::findPrevValidBucket ( vector< hashNode *, rebind_alloc_pointer > *  buckets,
u_integer  bucket 
)
staticprotected

Finds the previous non-empty bucket.

Parameters
bucketsReference to buckets vector
bucketStarting bucket index
Returns
Index of previous non-empty bucket or buckets.size() if none

◆ get() [1/2]

Gets current key-value pair (non-const)

Returns
Reference to current pair
Exceptions
outOfBoundErrorif iterator is invalid

◆ get() [2/2]

Gets current key-value pair (const)

Returns
Copy of current pair
Exceptions
outOfBoundErrorif iterator is invalid

◆ hasNext()

bool original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator::hasNext ( ) const

Checks if more elements are available.

Returns
true if more elements can be traversed

◆ isValid()

bool original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator::isValid ( ) const

Checks if iterator points to valid element.

Returns
true if iterator is valid

◆ next()

Advances to the next element.

Exceptions
outOfBoundErrorif already at end

◆ operator+=()

void original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::Iterator::operator+= ( integer  steps) const

Advances iterator by steps positions.

Parameters
stepsNumber of positions to advance (must be >= 0)
Exceptions
unSupportedMethodErrorif steps is negative

◆ operator=()

Copy assignment operator.

Parameters
otherIterator to copy from
Returns
Reference to this iterator

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