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>

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 auto operator* () const
 
constexpr StlEnumerateIteratoroperator++ () 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 1039 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 1043 of file ah-stl-zip.H.

◆ iterator_category

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

Definition at line 1042 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 1044 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 1052 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 1058 of file ah-stl-zip.H.

Member Function Documentation

◆ get_curr()

◆ has_curr()

◆ next()

◆ operator!=()

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

References Aleph::maps().

◆ 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 1048 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: