Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::UniZipIterator< Containers > Class Template Reference

Iterator that traverses multiple containers (STL or Aleph) in lockstep. More...

#include <ah-zip-utils.H>

Collaboration diagram for Aleph::UniZipIterator< Containers >:
[legend]

Public Types

using value_type = std::tuple< uni_zip_detail::container_value_t< Containers >... >
 

Public Member Functions

 UniZipIterator (const Containers &...cs)
 Constructor initializing wrappers for all containers.
 
bool has_curr () const noexcept
 Returns true if ALL containers have current element (zip continues)
 
bool any_has_curr () const noexcept
 Returns true if ANY container still has elements (for length checking)
 
bool all_completed () const noexcept
 Returns true if ALL containers are exhausted (equal length check)
 
bool completed () const noexcept
 Check if iterator has reached the end.
 
auto get_curr () const
 Get the current element.
 
void next ()
 Advance to the next element.
 
void next_ne ()
 Advance without checking; same as next(), which does not check.
 
auto operator* () const
 Dereference operator for STL compatibility.
 
UniZipIterator & operator++ ()
 Pre-increment operator for STL compatibility.
 
bool operator== (UniZipSentinel) const noexcept
 Comparison with sentinel - iterator is "at end" when any container exhausted.
 
bool operator!= (UniZipSentinel s) const noexcept
 Inequality comparison with sentinel.
 
bool operator== (const UniZipIterator &other) const noexcept
 Comparison with another iterator (for algorithms that need it)
 
bool operator!= (const UniZipIterator &other) const noexcept
 Inequality comparison with another iterator.
 

Static Public Attributes

static constexpr size_t num_containers = sizeof...(Containers)
 

Private Member Functions

template<size_t... Is>
bool has_curr_impl (std::index_sequence< Is... >) const noexcept
 
template<size_t... Is>
bool any_has_curr_impl (std::index_sequence< Is... >) const noexcept
 
template<size_t... Is>
bool all_completed_impl (std::index_sequence< Is... >) const noexcept
 
template<size_t... Is>
auto get_curr_impl (std::index_sequence< Is... >) const
 
template<size_t... Is>
void next_impl (std::index_sequence< Is... >)
 

Private Attributes

std::tuple< uni_zip_detail::iterator_wrapper_t< Containers >... > iters_
 

Detailed Description

template<typename... Containers>
class Aleph::UniZipIterator< Containers >

Iterator that traverses multiple containers (STL or Aleph) in lockstep.

This iterator automatically adapts to the container type, allowing you to zip together any combination of STL and Aleph containers.

Template Parameters
ContainersParameter pack of container types.
See also
uni_zip() Factory function
Author
Leandro Rabindranath León

Definition at line 339 of file ah-zip-utils.H.

Member Typedef Documentation

◆ value_type

template<typename... Containers>
using Aleph::UniZipIterator< Containers >::value_type = std::tuple<uni_zip_detail::container_value_t<Containers>...>

Definition at line 345 of file ah-zip-utils.H.

Constructor & Destructor Documentation

◆ UniZipIterator()

template<typename... Containers>
Aleph::UniZipIterator< Containers >::UniZipIterator ( const Containers &...  cs)
inlineexplicit

Constructor initializing wrappers for all containers.

Definition at line 384 of file ah-zip-utils.H.

Member Function Documentation

◆ all_completed()

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::all_completed ( ) const
inlinenoexcept

Returns true if ALL containers are exhausted (equal length check)

Definition at line 402 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::all_completed_impl().

Referenced by Aleph::UniZipIterator< Containers >::completed().

◆ all_completed_impl()

template<typename... Containers>
template<size_t... Is>
bool Aleph::UniZipIterator< Containers >::all_completed_impl ( std::index_sequence< Is... >  ) const
inlineprivatenoexcept

◆ any_has_curr()

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::any_has_curr ( ) const
inlinenoexcept

Returns true if ANY container still has elements (for length checking)

Definition at line 396 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::any_has_curr_impl().

◆ any_has_curr_impl()

template<typename... Containers>
template<size_t... Is>
bool Aleph::UniZipIterator< Containers >::any_has_curr_impl ( std::index_sequence< Is... >  ) const
inlineprivatenoexcept

◆ completed()

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::completed ( ) const
inlinenoexcept

Check if iterator has reached the end.

Deprecated:
Use all_completed() for clarity. Kept for backward compatibility.

Definition at line 409 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::all_completed().

Referenced by Aleph::UniZipIterator< Containers >::all_completed_impl().

◆ get_curr()

template<typename... Containers>
auto Aleph::UniZipIterator< Containers >::get_curr ( ) const
inline

Get the current element.

Get tuple of current elements from all containers

Definition at line 416 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::get_curr_impl().

Referenced by Aleph::UniZipIterator< Containers >::get_curr_impl(), Aleph::UniZipIterator< Containers >::operator*(), Aleph::uni_zip_assoc(), and Aleph::uni_zip_last().

◆ get_curr_impl()

template<typename... Containers>
template<size_t... Is>
auto Aleph::UniZipIterator< Containers >::get_curr_impl ( std::index_sequence< Is... >  ) const
inlineprivate

◆ has_curr()

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::has_curr ( ) const
inlinenoexcept

◆ has_curr_impl()

template<typename... Containers>
template<size_t... Is>
bool Aleph::UniZipIterator< Containers >::has_curr_impl ( std::index_sequence< Is... >  ) const
inlineprivatenoexcept

◆ next()

template<typename... Containers>
void Aleph::UniZipIterator< Containers >::next ( )
inline

Advance to the next element.

Advance all iterators

Definition at line 423 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::next_impl().

Referenced by Aleph::UniZipIterator< Containers >::next_ne(), and Aleph::UniZipIterator< Containers >::operator++().

◆ next_impl()

template<typename... Containers>
template<size_t... Is>
void Aleph::UniZipIterator< Containers >::next_impl ( std::index_sequence< Is... >  )
inlineprivate

◆ next_ne()

template<typename... Containers>
void Aleph::UniZipIterator< Containers >::next_ne ( )
inline

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

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

Definition at line 433 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::next().

◆ operator!=() [1/2]

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::operator!= ( const UniZipIterator< Containers > &  other) const
inlinenoexcept

Inequality comparison with another iterator.

Definition at line 472 of file ah-zip-utils.H.

◆ operator!=() [2/2]

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::operator!= ( UniZipSentinel  s) const
inlinenoexcept

Inequality comparison with sentinel.

Definition at line 459 of file ah-zip-utils.H.

◆ operator*()

template<typename... Containers>
auto Aleph::UniZipIterator< Containers >::operator* ( ) const
inline

Dereference operator for STL compatibility.

Definition at line 440 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::get_curr().

◆ operator++()

template<typename... Containers>
UniZipIterator & Aleph::UniZipIterator< Containers >::operator++ ( )
inline

Pre-increment operator for STL compatibility.

Definition at line 446 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::next().

◆ operator==() [1/2]

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::operator== ( const UniZipIterator< Containers > &  other) const
inlinenoexcept

Comparison with another iterator (for algorithms that need it)

Definition at line 465 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::has_curr().

◆ operator==() [2/2]

template<typename... Containers>
bool Aleph::UniZipIterator< Containers >::operator== ( UniZipSentinel  ) const
inlinenoexcept

Comparison with sentinel - iterator is "at end" when any container exhausted.

Definition at line 453 of file ah-zip-utils.H.

References Aleph::UniZipIterator< Containers >::has_curr().

Member Data Documentation

◆ iters_

◆ num_containers

template<typename... Containers>
constexpr size_t Aleph::UniZipIterator< Containers >::num_containers = sizeof...(Containers)
staticconstexpr

Definition at line 381 of file ah-zip-utils.H.


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