Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::DynListStack< T >::Iterator Struct Reference

Iterator for traversing elements of the stack. More...

#include <tpl_dynListStack.H>

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

Public Types

using Set_Type = DynListStack< T >
 The container type this iterator operates on.
 
using Base = typename DynList< T >::Iterator
 Base iterator type.
 
- Public Types inherited from Aleph::DynList< T >::Iterator
using Item_Type = T
 
using Iterator_Type = Iterator
 The type of elements of list.
 
using Set_Type = DynList
 

Public Member Functions

 Iterator (DynListStack< T > &stack) noexcept
 Construct an iterator for a stack.
 
 Iterator (const DynListStack< T > &)=delete
 A constant stack is iterated through Const_Iterator.
 
- Public Member Functions inherited from Aleph::DynList< T >::Iterator
 Iterator () noexcept=default
 The type of container.
 
 Iterator (DynList &list) noexcept
 Iterator on the modifiable list list.
 
 Iterator (const DynList &)=delete
 A constant list is iterated through Const_Iterator.
 
T & get_curr_ne () const noexcept
 Return the current link guaranteeing no exception. Be careful.
 
T & get_curr () const
 Return the current item.
 
T del ()
 Remove the current item of the iterator.
 
Slinknc * del_ne () noexcept
 Remove the current node, which the caller takes, and move the iterator forward; the iterator must have a current item.
 
- Public Member Functions inherited from Aleph::HTList::Iterator
 Iterator () noexcept=default
 
 Iterator (const HTList &list) noexcept
 Initialize iterator on at the first item of list
 
void reset () noexcept
 Reset the iterator at the first item.
 
long get_pos () const noexcept
 
void reset_first () noexcept
 See reset().
 
void reset_last ()
 It has O(n) of performance.
 
void end () noexcept
 Set the iterator to its end position, which has not.
 
 Iterator (const Iterator &)=default
 
Iterator & operator= (const Iterator &it) noexcept
 
bool has_curr () const noexcept
 
bool is_last () const noexcept
 
bool is_in_first () const noexcept
 Return true if the iterator is positioned on the first item.
 
bool is_in_last () const noexcept
 Return true if the iterator is positioned on the last item.
 
Slinknc * get_curr () const
 
Slinknc * get_curr_ne () const noexcept
 Return the current link guaranteeing no exception. Be careful.
 
void next_ne () noexcept
 Move the iterator one position forward guaranteeing no exception.
 
void next ()
 
Slinknc * del_ne () noexcept
 Remove the current item and move the iterator one position forward, without checking that there is a current item.
 
Slinknc * del ()
 

Additional Inherited Members

- Protected Member Functions inherited from Aleph::HTList::Iterator
HTList * get_list_ptr () const noexcept
 The list of the iterator, for the iterators of the derived lists.
 

Detailed Description

template<typename T>
struct Aleph::DynListStack< T >::Iterator

Iterator for traversing elements of the stack.

Provides forward iteration over stack elements in LIFO order (from top to bottom). This is the same order in which elements would be retrieved via successive pop() calls.

Example Usage

DynListStack<int> stack = {1, 2, 3};
// Using explicit iterator
for (auto it = stack.get_it(); it.has_curr(); it.next())
std::cout << it.get_curr() << " ";
// Using range-based for loop
for (const auto & item : stack)
std::cout << item << " ";
Dynamic stack of elements of generic type T based on a singly linked list.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Definition ah-dry.H:663
STL namespace.
Note
The iterator provides read-only access to elements. Modifying elements during iteration may invalidate the iterator.

Definition at line 525 of file tpl_dynListStack.H.

Member Typedef Documentation

◆ Base

template<typename T >
using Aleph::DynListStack< T >::Iterator::Base = typename DynList<T>::Iterator

Base iterator type.

Definition at line 531 of file tpl_dynListStack.H.

◆ Set_Type

template<typename T >
using Aleph::DynListStack< T >::Iterator::Set_Type = DynListStack<T>

The container type this iterator operates on.

Definition at line 528 of file tpl_dynListStack.H.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

template<typename T >
Aleph::DynListStack< T >::Iterator::Iterator ( DynListStack< T > &  stack)
inlinenoexcept

Construct an iterator for a stack.

Creates an iterator positioned at the top of the stack.

Parameters
[in]stackThe stack to iterate over. Iterator on the modifiable stack stack.

Definition at line 543 of file tpl_dynListStack.H.

◆ Iterator() [2/2]

template<typename T >
Aleph::DynListStack< T >::Iterator::Iterator ( const DynListStack< T > &  )
delete

A constant stack is iterated through Const_Iterator.


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