R-Type  2
Doom but in better
Loading...
Searching...
No Matches
IndexedZipperIterator< Containers > Class Template Reference

Iterator for traversing the elements of multiple zipped containers, paired with their indices. More...

#include <IndexedZipperIterator.hpp>

Collaboration diagram for IndexedZipperIterator< Containers >:
Collaboration graph

Public Types

using value = std::tuple<it_reference_t<Containers>...>
 Type alias for the value type returned by the iterator.
 
using value_type = std::tuple<std::size_t, it_reference_t<Containers>...>
 
using reference = value_type&
 
using pointer = void
 
using difference_type = std::size_t
 
using iterator_category = std::forward_iterator_tag
 
using iterator_tuple = std::tuple<iterator_t<Containers>...>
 Type alias for the tuple of iterators for the containers being iterated.
 

Public Member Functions

 IndexedZipperIterator (iterator_tuple it_tuple, std::size_t max, std::size_t idx=0)
 Constructs an IndexedZipperIterator with the current iterator positions and index.
 
 IndexedZipperIterator (const IndexedZipperIterator &z)
 Copy constructor.
 
IndexedZipperIteratoroperator++ ()
 Pre-increment operator.
 
IndexedZipperIterator operator++ (int)
 Post-increment operator.
 
value_type operator* ()
 Dereference operator.
 
value_typeoperator-> ()
 Member access operator.
 

Friends

bool operator== (const IndexedZipperIterator< Containers... > &lhs, const IndexedZipperIterator< Containers... > &rhs)
 Inequality operator.
 
bool operator!= (const IndexedZipperIterator< Containers... > &lhs, const IndexedZipperIterator< Containers... > &rhs)
 Equality operator.
 

Detailed Description

template<class... Containers>
class IndexedZipperIterator< Containers >

Iterator for traversing the elements of multiple zipped containers, paired with their indices.

The IndexedZipperIterator class facilitates iterating over a collection of containers, returning a tuple of the current index and references to the elements of the containers.

Template Parameters
ContainersVariadic template parameter for the types of containers being iterated over.

Definition at line 20 of file IndexedZipperIterator.hpp.

Member Typedef Documentation

◆ difference_type

template<class... Containers>
using IndexedZipperIterator< Containers >::difference_type = std::size_t

Difference type for iterator arithmetic.

Definition at line 35 of file IndexedZipperIterator.hpp.

◆ iterator_category

template<class... Containers>
using IndexedZipperIterator< Containers >::iterator_category = std::forward_iterator_tag

Iterator category.

Definition at line 36 of file IndexedZipperIterator.hpp.

◆ iterator_tuple

template<class... Containers>
using IndexedZipperIterator< Containers >::iterator_tuple = std::tuple<iterator_t<Containers>...>

Type alias for the tuple of iterators for the containers being iterated.

Definition at line 39 of file IndexedZipperIterator.hpp.

◆ pointer

template<class... Containers>
using IndexedZipperIterator< Containers >::pointer = void

Pointer type (not applicable for this iterator).

Definition at line 34 of file IndexedZipperIterator.hpp.

◆ reference

template<class... Containers>
using IndexedZipperIterator< Containers >::reference = value_type&

Reference type for the value.

Definition at line 33 of file IndexedZipperIterator.hpp.

◆ value

template<class... Containers>
using IndexedZipperIterator< Containers >::value = std::tuple<it_reference_t<Containers>...>

Type alias for the value type returned by the iterator.

Definition at line 31 of file IndexedZipperIterator.hpp.

◆ value_type

template<class... Containers>
using IndexedZipperIterator< Containers >::value_type = std::tuple<std::size_t, it_reference_t<Containers>...>

Definition at line 32 of file IndexedZipperIterator.hpp.

Constructor & Destructor Documentation

◆ IndexedZipperIterator() [1/2]

template<class... Containers>
IndexedZipperIterator< Containers >::IndexedZipperIterator ( iterator_tuple it_tuple,
std::size_t max,
std::size_t idx = 0 )
inline

Constructs an IndexedZipperIterator with the current iterator positions and index.

Parameters
it_tupleA tuple of iterators pointing to the current positions in the containers.
maxThe maximum number of elements to iterate over (determined by the smallest container size).

Definition at line 47 of file IndexedZipperIterator.hpp.

◆ IndexedZipperIterator() [2/2]

template<class... Containers>
IndexedZipperIterator< Containers >::IndexedZipperIterator ( const IndexedZipperIterator< Containers > & z)
inline

Copy constructor.

Parameters
zThe IndexedZipperIterator to copy.

Definition at line 54 of file IndexedZipperIterator.hpp.

Member Function Documentation

◆ operator*()

template<class... Containers>
value_type IndexedZipperIterator< Containers >::operator* ( )
inline

Dereference operator.

Returns the current index and references to the elements of the containers.

Returns
A tuple of the current index and references to the container elements.

Definition at line 88 of file IndexedZipperIterator.hpp.

◆ operator++() [1/2]

template<class... Containers>
IndexedZipperIterator & IndexedZipperIterator< Containers >::operator++ ( )
inline

Pre-increment operator.

Advances the iterator to the next element in the containers.

Returns
A reference to the incremented iterator.

Definition at line 63 of file IndexedZipperIterator.hpp.

◆ operator++() [2/2]

template<class... Containers>
IndexedZipperIterator IndexedZipperIterator< Containers >::operator++ ( int )
inline

Post-increment operator.

Advances the iterator to the next element in the containers.

Returns
A copy of the iterator before incrementing.

Definition at line 75 of file IndexedZipperIterator.hpp.

◆ operator->()

template<class... Containers>
value_type * IndexedZipperIterator< Containers >::operator-> ( )
inline

Member access operator.

Provides a pointer-like interface to the iterator's value.

Returns
A pointer to the value tuple.

Definition at line 99 of file IndexedZipperIterator.hpp.

Friends And Related Symbol Documentation

◆ operator!=

template<class... Containers>
bool operator!= ( const IndexedZipperIterator< Containers... > & lhs,
const IndexedZipperIterator< Containers... > & rhs )
friend

Equality operator.

Compares two iterators for equality.

Parameters
lhsLeft-hand side iterator.
rhsRight-hand side iterator.
Returns
true if the iterators are equal; otherwise false.

Definition at line 125 of file IndexedZipperIterator.hpp.

◆ operator==

template<class... Containers>
bool operator== ( const IndexedZipperIterator< Containers... > & lhs,
const IndexedZipperIterator< Containers... > & rhs )
friend

Inequality operator.

Compares two iterators for inequality.

Parameters
lhsLeft-hand side iterator.
rhsRight-hand side iterator.
Returns
true if the iterators are not equal; otherwise false.

Definition at line 112 of file IndexedZipperIterator.hpp.


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