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

Forward iterator for skipList. More...

#include <skipList.h>

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

Protected Member Functions

 Iterator (skipListNode *cur=nullptr)
 Constructs iterator.
 
 Iterator (const Iterator &other)
 Copy constructor.
 
Iteratoroperator= (const Iterator &other)
 Copy assignment operator.
 
bool hasNext () const
 Checks if more elements exist forward.
 
void next () const
 Moves to next element.
 
Iteratorclone () const
 Creates a copy of this iterator.
 
void operator+= (integer steps) const
 Advances iterator by steps.
 
integer operator- (const Iterator &other) const
 Calculates distance between iterators.
 
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.
 

Static Protected Member Functions

static integer ptrDistance (const Iterator *start, const Iterator *end)
 Calculates distance between two iterators.
 

Protected Attributes

skipListNodecur_
 Current node pointer.
 

Detailed Description

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

Forward iterator for skipList.

Provides iteration over list elements in sorted order

Constructor & Destructor Documentation

◆ Iterator()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
original::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::Iterator ( skipListNode * cur = nullptr)
explicitprotected

Constructs iterator.

Parameters
curCurrent node pointer

Member Function Documentation

◆ clone()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
original::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator * original::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::clone ( ) const
protected

Creates a copy of this iterator.

Returns
Pointer to new iterator

◆ get() [1/2]

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

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::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::get ( ) const
protected

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::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::hasNext ( ) const
nodiscardprotected

Checks if more elements exist forward.

Returns
true if more elements available

◆ isValid()

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

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::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::operator+= ( original::integer steps) const
protected

Advances iterator by steps.

Parameters
stepsNumber of positions to advance

◆ operator-()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
original::integer original::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::operator- ( const Iterator & other) const
protected

Calculates distance between iterators.

Parameters
otherIterator to compare with
Returns
Distance between iterators

◆ ptrDistance()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename Compare>
original::integer original::skipList< K_TYPE, V_TYPE, ALLOC, Compare >::Iterator::ptrDistance ( const Iterator * start,
const Iterator * end )
staticprotected

Calculates distance between two iterators.

Parameters
startStarting iterator
endEnding iterator
Returns
Distance between iterators

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