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

Iterator for traversing multiple zipped containers simultaneously. More...

#include <ZipperIterator.hpp>

Collaboration diagram for ZipperIterator< Containers >:
Collaboration graph

Public Types

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

Public Member Functions

 ZipperIterator (iterator_tuple const &it_tuple, std::size_t max, std::size_t idx=0)
 Constructs a ZipperIterator with the provided iterator tuple and maximum iteration count.
 
 ZipperIterator (const ZipperIterator &z)
 Copy constructor.
 
ZipperIteratoroperator++ ()
 Pre-increment operator.
 
ZipperIterator operator++ (int)
 Post-increment operator.
 
value_type operator* ()
 Dereference operator.
 
value_typeoperator-> ()
 Member access operator.
 

Friends

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

Detailed Description

template<class... Containers>
class ZipperIterator< Containers >

Iterator for traversing multiple zipped containers simultaneously.

The ZipperIterator class enables simultaneous iteration over multiple containers. It returns a tuple containing references to the elements at the same position in the zipped containers.

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

Definition at line 20 of file ZipperIterator.hpp.

Member Typedef Documentation

◆ difference_type

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

Difference type for iterator arithmetic.

Definition at line 34 of file ZipperIterator.hpp.

◆ iterator_category

template<class... Containers>
using ZipperIterator< Containers >::iterator_category = std::input_iterator_tag

Iterator category.

Definition at line 35 of file ZipperIterator.hpp.

◆ iterator_tuple

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

Type alias for the tuple of iterators used in the zipped containers.

Definition at line 38 of file ZipperIterator.hpp.

◆ pointer

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

Pointer type (not applicable for this iterator).

Definition at line 33 of file ZipperIterator.hpp.

◆ reference

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

Reference type for the value.

Definition at line 32 of file ZipperIterator.hpp.

◆ value_type

template<class... Containers>
using ZipperIterator< Containers >::value_type = std::tuple<it_reference_t<Containers>...>

Type alias for the value type returned by the iterator.

Definition at line 31 of file ZipperIterator.hpp.

Constructor & Destructor Documentation

◆ ZipperIterator() [1/2]

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

Constructs a ZipperIterator with the provided iterator tuple and maximum iteration count.

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 46 of file ZipperIterator.hpp.

◆ ZipperIterator() [2/2]

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

Copy constructor.

Parameters
zThe ZipperIterator to copy.

Definition at line 53 of file ZipperIterator.hpp.

Member Function Documentation

◆ operator*()

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

Dereference operator.

Returns a tuple containing references to the elements of the containers at the current position.

Returns
A tuple of references to the container elements at the current position.

Definition at line 87 of file ZipperIterator.hpp.

◆ operator++() [1/2]

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

Pre-increment operator.

Advances the iterator to the next position in all containers.

Returns
A reference to the incremented iterator.

Definition at line 62 of file ZipperIterator.hpp.

◆ operator++() [2/2]

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

Post-increment operator.

Advances the iterator to the next position in all containers.

Returns
A copy of the iterator before incrementing.

Definition at line 74 of file ZipperIterator.hpp.

◆ operator->()

template<class... Containers>
value_type * ZipperIterator< 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 98 of file ZipperIterator.hpp.

Friends And Related Symbol Documentation

◆ operator!=

template<class... Containers>
bool operator!= ( const ZipperIterator< Containers... > & lhs,
const ZipperIterator< 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 124 of file ZipperIterator.hpp.

◆ operator==

template<class... Containers>
bool operator== ( const ZipperIterator< Containers... > & lhs,
const ZipperIterator< 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 111 of file ZipperIterator.hpp.


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