Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::StlEnumerateIterator< Container > Class Template Reference

Iterator that pairs each element with its index. More...

#include <ah-stl-zip.H>

Collaboration diagram for Aleph::StlEnumerateIterator< Container >:
[legend]

Classes

struct  end_tag
 

Public Types

using iterator_category = std::input_iterator_tag
 
using difference_type = std::ptrdiff_t
 
using value_type = std::tuple< size_t, typename std::decay_t< Container >::value_type >
 

Public Member Functions

constexpr StlEnumerateIterator (const Container &c)
 
constexpr StlEnumerateIterator (const Container &c, end_tag)
 
constexpr bool has_curr () const noexcept
 
constexpr auto get_curr () const
 
constexpr void next () noexcept
 
constexpr void next_ne () noexcept
 Advance without checking; same as next(), which does not check.
 
constexpr auto operator* () const
 
constexpr StlEnumerateIterator & operator++ () noexcept
 
constexpr bool operator== (const StlEnumerateIterator &other) const noexcept
 
constexpr bool operator!= (const StlEnumerateIterator &other) const noexcept
 

Private Attributes

std::decay_t< Container >::const_iterator curr_
 
std::decay_t< Container >::const_iterator end_
 
size_t index_ = 0
 

Detailed Description

template<typename Container>
class Aleph::StlEnumerateIterator< Container >

Iterator that pairs each element with its index.

Similar to Python's enumerate(). Produces tuples of (index, element).

Template Parameters
ContainerContainer type.
See also
stl_enumerate() Factory function
Author
Leandro Rabindranath León

Definition at line 1046 of file ah-stl-zip.H.

Member Typedef Documentation

◆ difference_type

template<typename Container >
using Aleph::StlEnumerateIterator< Container >::difference_type = std::ptrdiff_t

Definition at line 1050 of file ah-stl-zip.H.

◆ iterator_category

template<typename Container >
using Aleph::StlEnumerateIterator< Container >::iterator_category = std::input_iterator_tag

Definition at line 1049 of file ah-stl-zip.H.

◆ value_type

template<typename Container >
using Aleph::StlEnumerateIterator< Container >::value_type = std::tuple<size_t, typename std::decay_t<Container>::value_type>

Definition at line 1051 of file ah-stl-zip.H.

Constructor & Destructor Documentation

◆ StlEnumerateIterator() [1/2]

template<typename Container >
constexpr Aleph::StlEnumerateIterator< Container >::StlEnumerateIterator ( const Container &  c)
inlineexplicitconstexpr

Definition at line 1059 of file ah-stl-zip.H.

◆ StlEnumerateIterator() [2/2]

template<typename Container >
constexpr Aleph::StlEnumerateIterator< Container >::StlEnumerateIterator ( const Container &  c,
end_tag   
)
inlineconstexpr

Definition at line 1065 of file ah-stl-zip.H.

Member Function Documentation

◆ get_curr()

◆ has_curr()

◆ next()

◆ next_ne()

template<typename Container >
constexpr void Aleph::StlEnumerateIterator< Container >::next_ne ( )
inlineconstexprnoexcept

Advance without checking; same as next(), which does not check.

Provided so the iterator satisfies AlephIterator and works in generic code that advances with next_ne() under a has_curr() guard.

Definition at line 1083 of file ah-stl-zip.H.

References Aleph::StlEnumerateIterator< Container >::next().

◆ operator!=()

◆ operator*()

◆ operator++()

◆ operator==()

Member Data Documentation

◆ curr_

◆ end_

template<typename Container >
std::decay_t<Container>::const_iterator Aleph::StlEnumerateIterator< Container >::end_
private

Definition at line 1055 of file ah-stl-zip.H.

Referenced by Aleph::StlEnumerateIterator< Container >::has_curr().

◆ index_


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