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

Iterator over singly linked nodes. More...

#include <tpl_slist.H>

Inheritance diagram for Aleph::Slist< T >::Iterator:
[legend]
Collaboration diagram for Aleph::Slist< T >::Iterator:
[legend]

Public Types

typedef Snode< TSet_Type
 Type of the set being iterated.
 
typedef Snode< T > * Item_Type
 Type of the element returned by get_curr().
 

Public Member Functions

 Iterator (Slist &_list) noexcept
 Construct an iterator over list.
 
bool has_curr () const noexcept
 Return true if the iterator currently points to a node.
 
Nodeget_curr ()
 Return the current node.
 
void next ()
 Advance the iterator to the next node.
 
void reset_first () noexcept
 Reset the iterator to the first node of the list.
 
Iteratoroperator= (Node *node)
 Assign the iterator to point to node.
 

Private Attributes

Slistlist
 
Nodecurrent
 

Detailed Description

template<typename T>
class Aleph::Slist< T >::Iterator

Iterator over singly linked nodes.

This iterator walks the list from the head sentinel forward.

See also
Slist

Definition at line 173 of file tpl_slist.H.

Member Typedef Documentation

◆ Item_Type

template<typename T >
typedef Snode<T>* Aleph::Slist< T >::Iterator::Item_Type

Type of the element returned by get_curr().

Definition at line 185 of file tpl_slist.H.

◆ Set_Type

template<typename T >
typedef Snode<T> Aleph::Slist< T >::Iterator::Set_Type

Type of the set being iterated.

Definition at line 183 of file tpl_slist.H.

Constructor & Destructor Documentation

◆ Iterator()

template<typename T >
Aleph::Slist< T >::Iterator::Iterator ( Slist _list)
inlineexplicitnoexcept

Construct an iterator over list.

Parameters
[in]_listlist to traverse

Definition at line 191 of file tpl_slist.H.

Member Function Documentation

◆ get_curr()

template<typename T >
Node * Aleph::Slist< T >::Iterator::get_curr ( )
inline

Return the current node.

Returns
pointer to the current node
Exceptions
overflow_errorif the iterator is not positioned on a node

Definition at line 205 of file tpl_slist.H.

References ah_overflow_error_if, Aleph::Slist< T >::Iterator::current, Aleph::Slist< T >::Iterator::has_curr(), and Aleph::maps().

Referenced by Aleph::DynSlist< T >::Iterator::get_curr(), Aleph::DynSlist< T >::Iterator::get_curr(), and TEST().

◆ has_curr()

template<typename T >
bool Aleph::Slist< T >::Iterator::has_curr ( ) const
inlinenoexcept

Return true if the iterator currently points to a node.

Definition at line 198 of file tpl_slist.H.

References Aleph::Slist< T >::Iterator::current, and Aleph::Slist< T >::Iterator::list.

Referenced by Aleph::Slist< T >::Iterator::get_curr(), Aleph::Slist< T >::Iterator::next(), TEST(), TEST(), and TEST().

◆ next()

template<typename T >
void Aleph::Slist< T >::Iterator::next ( )
inline

Advance the iterator to the next node.

Exceptions
overflow_errorif the iterator is not positioned on a node

Definition at line 215 of file tpl_slist.H.

References ah_overflow_error_if, Aleph::Slist< T >::Iterator::current, Aleph::Snode< T >::get_next(), Aleph::Slist< T >::Iterator::has_curr(), and Aleph::maps().

Referenced by TEST(), and TEST().

◆ operator=()

template<typename T >
Iterator & Aleph::Slist< T >::Iterator::operator= ( Node node)
inline

Assign the iterator to point to node.

Parameters
[in]nodenode to point to
Returns
reference to this iterator

Definition at line 233 of file tpl_slist.H.

References Aleph::Slist< T >::Iterator::current.

◆ reset_first()

template<typename T >
void Aleph::Slist< T >::Iterator::reset_first ( )
inlinenoexcept

Reset the iterator to the first node of the list.

Definition at line 223 of file tpl_slist.H.

References Aleph::Slist< T >::Iterator::current, Aleph::Slist< T >::get_first_ne(), Aleph::Slink::is_empty(), and Aleph::Slist< T >::Iterator::list.

Member Data Documentation

◆ current

◆ list

template<typename T >
Slist* Aleph::Slist< T >::Iterator::list
private

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