Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::SkipList< Key, Type >::Iterator Class Reference

Iterator for traversing SkipList elements in ascending order. More...

#include <tpl_skipList.H>

Collaboration diagram for Aleph::SkipList< Key, Type >::Iterator:
[legend]

Public Types

using Set_Type = SkipList
 

Public Member Functions

 Iterator () noexcept=default
 Default constructor (invalid iterator).
 
 Iterator (const Iterator &) noexcept=default
 
 Iterator (const SkipList &list) noexcept
 Construct iterator positioned at first element.
 
bool has_curr () const noexcept
 Check if iterator has a current element.
 
bool is_last () const noexcept
 Check if iterator is on the last element.
 
Nodeget_curr () const
 Get current node (throws if no current).
 
Nodeget_curr_ne () const noexcept
 Get current node without exception check.
 
const Key & get_key () const
 Get current key (throws if no current).
 
const Typeget_data () const
 Get current data (throws if no current).
 
void next ()
 Advance to next element (throws if no current).
 
void next_ne () noexcept
 Advance to next element without exception check.
 
void reset_first () noexcept
 Reset iterator to first element.
 
void reset () noexcept
 Reset iterator to first element (alias).
 
Iteratoroperator= (const Iterator &it) noexcept
 Assignment operator.
 
bool operator== (const Iterator &it) const noexcept
 Equality comparison.
 
bool operator!= (const Iterator &it) const noexcept
 Inequality comparison.
 
Iteratoroperator++ () noexcept
 Prefix increment operator.
 
Iterator operator++ (int) noexcept
 Postfix increment operator.
 
Nodeoperator* () const
 Dereference operator (returns node pointer).
 
Nodeoperator-> () const
 Arrow operator (returns node pointer).
 

Private Attributes

const SkipListlist_ptr = nullptr
 
Nodecurr = nullptr
 

Detailed Description

template<class Key, class Type>
class Aleph::SkipList< Key, Type >::Iterator

Iterator for traversing SkipList elements in ascending order.

Provides forward iteration over all elements in the skip list. Elements are visited in key order (smallest to largest).

Usage:

for (SkipList<int,int>::Iterator it(sl); it.has_curr(); it.next())
std::cout << it.get_curr()->get_key() << '\n';
Iterator for traversing SkipList elements in ascending order.
bool has_curr() const noexcept
Check if iterator has a current element.
Skip List - a probabilistic ordered data structure.

Definition at line 487 of file tpl_skipList.H.

Member Typedef Documentation

◆ Set_Type

template<class Key , class Type >
using Aleph::SkipList< Key, Type >::Iterator::Set_Type = SkipList

Definition at line 493 of file tpl_skipList.H.

Constructor & Destructor Documentation

◆ Iterator() [1/3]

template<class Key , class Type >
Aleph::SkipList< Key, Type >::Iterator::Iterator ( )
defaultnoexcept

Default constructor (invalid iterator).

◆ Iterator() [2/3]

template<class Key , class Type >
Aleph::SkipList< Key, Type >::Iterator::Iterator ( const Iterator )
defaultnoexcept

◆ Iterator() [3/3]

template<class Key , class Type >
Aleph::SkipList< Key, Type >::Iterator::Iterator ( const SkipList list)
inlinenoexcept

Construct iterator positioned at first element.

Parameters
[in]listSkipList to iterate over.

Definition at line 502 of file tpl_skipList.H.

Member Function Documentation

◆ get_curr()

template<class Key , class Type >
Node * Aleph::SkipList< Key, Type >::Iterator::get_curr ( ) const
inline

Get current node (throws if no current).

Returns
Pointer to current node.
Exceptions
std::overflow_errorif no current element.

Definition at line 526 of file tpl_skipList.H.

References ah_overflow_error_if.

◆ get_curr_ne()

template<class Key , class Type >
Node * Aleph::SkipList< Key, Type >::Iterator::get_curr_ne ( ) const
inlinenoexcept

Get current node without exception check.

Returns
Pointer to current node (may be nullptr).

Definition at line 535 of file tpl_skipList.H.

◆ get_data()

template<class Key , class Type >
const Type & Aleph::SkipList< Key, Type >::Iterator::get_data ( ) const
inline

Get current data (throws if no current).

Definition at line 541 of file tpl_skipList.H.

References Aleph::get_curr().

◆ get_key()

template<class Key , class Type >
const Key & Aleph::SkipList< Key, Type >::Iterator::get_key ( ) const
inline

Get current key (throws if no current).

Definition at line 538 of file tpl_skipList.H.

References Aleph::get_curr().

◆ has_curr()

template<class Key , class Type >
bool Aleph::SkipList< Key, Type >::Iterator::has_curr ( ) const
inlinenoexcept

Check if iterator has a current element.

Returns
true if positioned on a valid element.

Definition at line 512 of file tpl_skipList.H.

◆ is_last()

template<class Key , class Type >
bool Aleph::SkipList< Key, Type >::Iterator::is_last ( ) const
inlinenoexcept

Check if iterator is on the last element.

Definition at line 515 of file tpl_skipList.H.

References Aleph::SkipList< Key, Type >::Node::get_next(), and Aleph::next().

◆ next()

template<class Key , class Type >
void Aleph::SkipList< Key, Type >::Iterator::next ( )
inline

Advance to next element (throws if no current).

Definition at line 544 of file tpl_skipList.H.

References ah_overflow_error_if, and Aleph::next_ne().

◆ next_ne()

template<class Key , class Type >
void Aleph::SkipList< Key, Type >::Iterator::next_ne ( )
inlinenoexcept

Advance to next element without exception check.

Definition at line 551 of file tpl_skipList.H.

References Aleph::SkipList< Key, Type >::Node::get_next().

◆ operator!=()

template<class Key , class Type >
bool Aleph::SkipList< Key, Type >::Iterator::operator!= ( const Iterator it) const
inlinenoexcept

Inequality comparison.

Definition at line 589 of file tpl_skipList.H.

◆ operator*()

template<class Key , class Type >
Node * Aleph::SkipList< Key, Type >::Iterator::operator* ( ) const
inline

Dereference operator (returns node pointer).

Definition at line 610 of file tpl_skipList.H.

References Aleph::get_curr().

◆ operator++() [1/2]

template<class Key , class Type >
Iterator & Aleph::SkipList< Key, Type >::Iterator::operator++ ( )
inlinenoexcept

Prefix increment operator.

Definition at line 595 of file tpl_skipList.H.

References Aleph::next_ne().

◆ operator++() [2/2]

template<class Key , class Type >
Iterator Aleph::SkipList< Key, Type >::Iterator::operator++ ( int  )
inlinenoexcept

Postfix increment operator.

Definition at line 602 of file tpl_skipList.H.

References Aleph::next_ne().

◆ operator->()

template<class Key , class Type >
Node * Aleph::SkipList< Key, Type >::Iterator::operator-> ( ) const
inline

Arrow operator (returns node pointer).

Definition at line 613 of file tpl_skipList.H.

References Aleph::get_curr().

◆ operator=()

template<class Key , class Type >
Iterator & Aleph::SkipList< Key, Type >::Iterator::operator= ( const Iterator it)
inlinenoexcept

Assignment operator.

Definition at line 575 of file tpl_skipList.H.

◆ operator==()

template<class Key , class Type >
bool Aleph::SkipList< Key, Type >::Iterator::operator== ( const Iterator it) const
inlinenoexcept

Equality comparison.

Definition at line 583 of file tpl_skipList.H.

◆ reset()

template<class Key , class Type >
void Aleph::SkipList< Key, Type >::Iterator::reset ( )
inlinenoexcept

Reset iterator to first element (alias).

Definition at line 572 of file tpl_skipList.H.

◆ reset_first()

template<class Key , class Type >
void Aleph::SkipList< Key, Type >::Iterator::reset_first ( )
inlinenoexcept

Reset iterator to first element.

Definition at line 561 of file tpl_skipList.H.

References Aleph::SkipList< Key, Type >::headerPtr.

Member Data Documentation

◆ curr

template<class Key , class Type >
Node* Aleph::SkipList< Key, Type >::Iterator::curr = nullptr
private

Definition at line 490 of file tpl_skipList.H.

◆ list_ptr

template<class Key , class Type >
const SkipList* Aleph::SkipList< Key, Type >::Iterator::list_ptr = nullptr
private

Definition at line 489 of file tpl_skipList.H.


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