ORIGINAL
Loading...
Searching...
No Matches
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator Class Reference

Bidirectional iterator for RBTree. More...

#include <RBTree.h>

Collaboration diagram for original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator:
Collaboration graph

Public Member Functions

bool hasNext () const
 Checks if more elements exist forward.
 
bool hasPrev () const
 Checks if more elements exist backward.
 
void next () const
 Moves to next element.
 
void prev () const
 Moves to previous element.
 
void operator+= (integer steps) const
 Advances iterator by steps.
 
void operator-= (integer steps) const
 Moves iterator backward by steps.
 
couple< const K_TYPE, V_TYPE > & get ()
 Gets current element (non-const)
 
couple< const K_TYPE, V_TYPE > get () const
 Gets current element (const)
 
bool isValid () const
 Checks if iterator is valid.
 

Protected Member Functions

 Iterator (RBTree *tree=nullptr, RBNode *cur=nullptr)
 Constructs iterator.
 
 Iterator (const Iterator &other)
 Copy constructor.
 
Iteratoroperator= (const Iterator &other)
 Copy assignment operator.
 

Protected Attributes

RBTreetree_
 Owning tree.
 
RBNodecur_
 Current node.
 

Detailed Description

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<K_TYPE>, typename Compare = increaseComparator<K_TYPE>>
class original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator

Bidirectional iterator for RBTree.

Provides iteration over tree elements in sorted order

Constructor & Destructor Documentation

◆ Iterator()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::Iterator ( RBTree * tree = nullptr,
RBNode * cur = nullptr )
explicitprotected

Constructs iterator.

Parameters
treeOwning tree
curCurrent node

Member Function Documentation

◆ get() [1/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
original::couple< const K_TYPE, V_TYPE > & original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::get ( )

Gets current element (non-const)

Returns
Reference to current key-value pair

◆ get() [2/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
original::couple< const K_TYPE, V_TYPE > original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::get ( ) const

Gets current element (const)

Returns
Copy of current key-value pair

◆ hasNext()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
bool original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::hasNext ( ) const
nodiscard

Checks if more elements exist forward.

Returns
true if more elements available

◆ hasPrev()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
bool original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::hasPrev ( ) const
nodiscard

Checks if more elements exist backward.

Returns
true if more elements available

◆ isValid()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
bool original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::isValid ( ) const
nodiscard

Checks if iterator is valid.

Returns
true if iterator points to valid element

◆ operator+=()

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

Advances iterator by steps.

Parameters
stepsNumber of positions to advance

◆ operator-=()

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

Moves iterator backward by steps.

Parameters
stepsNumber of positions to move back

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