Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
StlIterator< SetType > Struct Template Reference

STL-compatible mutable iterator adapter for Aleph containers. More...

#include <ah-iterator.H>

Inheritance diagram for StlIterator< SetType >:
[legend]
Collaboration diagram for StlIterator< SetType >:
[legend]

Public Types

using T = typename SetType::Item_Type
 
using Itor = typename SetType::Iterator
 
using iterator_category = std::conditional_t< AlephRandomAccessItor< Itor >, std::random_access_iterator_tag, std::forward_iterator_tag >
 Category is promoted to random-access when the underlying Aleph iterator opts in (see AlephRandomAccessItor); otherwise it stays forward, which is the historical default and never a regression.
 
using iterator_concept = iterator_category
 
using difference_type = std::ptrdiff_t
 
using reference = decltype(std::declval< const Itor & >().get_curr())
 
using pointer = std::add_pointer_t< std::remove_reference_t< reference > >
 
using value_type = T
 

Public Member Functions

 StlIterator () noexcept=default
 Default constructor creates an "end" iterator (no current element).
 
StlIterator & operator++ ()
 Pre-increment: advance to the next element.
 
StlIterator operator++ (int)
 Post-increment: advance to the next element and return the old iterator.
 
bool operator== (const StlIterator &it) const
 Equality compares positions when both iterators are valid; otherwise both must be in the end state.
 
bool operator!= (const StlIterator &it) const
 Inequality.
 
reference operator* () const
 Dereference: return the current element.
 
pointer operator-> () const
 Member access to the current element.
 
StlIterator & operator-- ()
 Pre-decrement: move to the previous element.
 
StlIterator operator-- (int)
 Post-decrement: move to the previous element and return the old iterator.
 
StlIterator & operator+= (difference_type n)
 Advance the iterator n positions (n may be negative).
 
StlIterator & operator-= (difference_type n)
 Move the iterator back n positions (n may be negative).
 
StlIterator operator+ (difference_type n) const
 Return an iterator advanced n positions.
 
StlIterator operator- (difference_type n) const
 Return an iterator moved back n positions.
 
difference_type operator- (const StlIterator &it) const
 Return the signed distance between two iterators.
 
reference operator[] (difference_type n) const
 Access the element n positions away from the current one.
 
std::strong_ordering operator<=> (const StlIterator &it) const
 Order two iterators by their logical position.
 

Static Public Member Functions

static StlIterator begin (SetType &s)
 Create an iterator positioned at the first element of the container.
 
static StlIterator end (SetType &s)
 Create an end iterator for the container.
 

Friends

StlIterator operator+ (difference_type n, const StlIterator &it)
 Return an iterator advanced n positions (symmetric form).
 

Detailed Description

template<class SetType>
struct StlIterator< SetType >

STL-compatible mutable iterator adapter for Aleph containers.

This adapter wraps an Aleph-style iterator (SetType::Iterator) and exposes the operations expected by the STL and C++20 ranges.

Template Parameters
SetTypeAleph container type.
Note
Requirements on SetType::Iterator:
  • Constructible from SetType&.
  • bool has_curr() const.
  • void next().
  • auto & get_curr() const returning the current element.
  • auto get_pos() const returning a position that is stable and comparable between iterators over the same container.
  • void end() to move the iterator to the end sentinel.

Definition at line 98 of file ah-iterator.H.

Member Typedef Documentation

◆ difference_type

template<class SetType >
using StlIterator< SetType >::difference_type = std::ptrdiff_t

Definition at line 110 of file ah-iterator.H.

◆ iterator_category

template<class SetType >
using StlIterator< SetType >::iterator_category = std::conditional_t<AlephRandomAccessItor<Itor>, std::random_access_iterator_tag, std::forward_iterator_tag>

Category is promoted to random-access when the underlying Aleph iterator opts in (see AlephRandomAccessItor); otherwise it stays forward, which is the historical default and never a regression.

Definition at line 106 of file ah-iterator.H.

◆ iterator_concept

template<class SetType >
using StlIterator< SetType >::iterator_concept = iterator_category

Definition at line 108 of file ah-iterator.H.

◆ Itor

template<class SetType >
using StlIterator< SetType >::Itor = typename SetType::Iterator

Definition at line 101 of file ah-iterator.H.

◆ pointer

template<class SetType >
using StlIterator< SetType >::pointer = std::add_pointer_t<std::remove_reference_t<reference> >

Definition at line 114 of file ah-iterator.H.

◆ reference

template<class SetType >
using StlIterator< SetType >::reference = decltype(std::declval<const Itor &>().get_curr())

Definition at line 112 of file ah-iterator.H.

◆ T

template<class SetType >
using StlIterator< SetType >::T = typename SetType::Item_Type

Definition at line 100 of file ah-iterator.H.

◆ value_type

template<class SetType >
using StlIterator< SetType >::value_type = T

Definition at line 116 of file ah-iterator.H.

Constructor & Destructor Documentation

◆ StlIterator()

template<class SetType >
StlIterator< SetType >::StlIterator ( )
defaultnoexcept

Default constructor creates an "end" iterator (no current element).

Referenced by StlIterator< SetType >::begin().

Member Function Documentation

◆ begin()

template<class SetType >
static StlIterator StlIterator< SetType >::begin ( SetType &  s)
inlinestatic

Create an iterator positioned at the first element of the container.

Definition at line 264 of file ah-iterator.H.

References StlIterator< SetType >::StlIterator().

Referenced by StlAlephIterator< SetName >::begin().

◆ end()

template<class SetType >
static StlIterator StlIterator< SetType >::end ( SetType &  s)
inlinestatic

Create an end iterator for the container.

Definition at line 270 of file ah-iterator.H.

Referenced by StlAlephIterator< SetName >::end().

◆ operator!=()

template<class SetType >
bool StlIterator< SetType >::operator!= ( const StlIterator< SetType > &  it) const
inline

Inequality.

Definition at line 158 of file ah-iterator.H.

◆ operator*()

template<class SetType >
reference StlIterator< SetType >::operator* ( ) const
inline

Dereference: return the current element.

Definition at line 166 of file ah-iterator.H.

◆ operator+()

template<class SetType >
StlIterator StlIterator< SetType >::operator+ ( difference_type  n) const
inline

Return an iterator advanced n positions.

Definition at line 216 of file ah-iterator.H.

◆ operator++() [1/2]

template<class SetType >
StlIterator & StlIterator< SetType >::operator++ ( )
inline

Pre-increment: advance to the next element.

Definition at line 124 of file ah-iterator.H.

◆ operator++() [2/2]

template<class SetType >
StlIterator StlIterator< SetType >::operator++ ( int  )
inline

Post-increment: advance to the next element and return the old iterator.

Definition at line 131 of file ah-iterator.H.

◆ operator+=()

template<class SetType >
StlIterator & StlIterator< SetType >::operator+= ( difference_type  n)
inline

Advance the iterator n positions (n may be negative).

Definition at line 200 of file ah-iterator.H.

◆ operator-() [1/2]

template<class SetType >
difference_type StlIterator< SetType >::operator- ( const StlIterator< SetType > &  it) const
inline

Return the signed distance between two iterators.

Definition at line 241 of file ah-iterator.H.

◆ operator-() [2/2]

template<class SetType >
StlIterator StlIterator< SetType >::operator- ( difference_type  n) const
inline

Return an iterator moved back n positions.

Definition at line 232 of file ah-iterator.H.

◆ operator--() [1/2]

template<class SetType >
StlIterator & StlIterator< SetType >::operator-- ( )
inline

Pre-decrement: move to the previous element.

Definition at line 183 of file ah-iterator.H.

◆ operator--() [2/2]

template<class SetType >
StlIterator StlIterator< SetType >::operator-- ( int  )
inline

Post-decrement: move to the previous element and return the old iterator.

Definition at line 191 of file ah-iterator.H.

◆ operator-=()

template<class SetType >
StlIterator & StlIterator< SetType >::operator-= ( difference_type  n)
inline

Move the iterator back n positions (n may be negative).

Definition at line 208 of file ah-iterator.H.

◆ operator->()

template<class SetType >
pointer StlIterator< SetType >::operator-> ( ) const
inline

Member access to the current element.

Definition at line 172 of file ah-iterator.H.

◆ operator<=>()

template<class SetType >
std::strong_ordering StlIterator< SetType >::operator<=> ( const StlIterator< SetType > &  it) const
inline

Order two iterators by their logical position.

Definition at line 257 of file ah-iterator.H.

◆ operator==()

template<class SetType >
bool StlIterator< SetType >::operator== ( const StlIterator< SetType > &  it) const
inline

Equality compares positions when both iterators are valid; otherwise both must be in the end state.

Definition at line 140 of file ah-iterator.H.

◆ operator[]()

template<class SetType >
reference StlIterator< SetType >::operator[] ( difference_type  n) const
inline

Access the element n positions away from the current one.

Definition at line 248 of file ah-iterator.H.

Friends And Related Symbol Documentation

◆ operator+

template<class SetType >
StlIterator operator+ ( difference_type  n,
const StlIterator< SetType > &  it 
)
friend

Return an iterator advanced n positions (symmetric form).

Definition at line 225 of file ah-iterator.H.


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