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

Lazy view over multiple zipped STL containers. More...

#include <ah-stl-zip.H>

Public Types

using iterator = StlZipIterator< std::decay_t< Containers >... >
 
using const_iterator = iterator
 
using value_type = typename iterator::value_type
 

Public Member Functions

constexpr StlZipView (const Containers &... cs)
 Construct view from containers.
 
constexpr iterator begin () const
 Get iterator to beginning.
 
constexpr iterator end () const
 Get iterator to end.
 
constexpr bool empty () const
 Check if view is empty.
 
size_t size () const
 Get number of tuples (minimum size of all containers).
 

Private Attributes

std::tuple< const std::decay_t< Containers > &... > containers_
 

Detailed Description

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

Lazy view over multiple zipped STL containers.

This class provides a range interface for zipping containers without materializing the result. It can be used with range-based for loops and integrates with STL algorithms.

Memory Efficiency:

Unlike std::vector of tuples approaches, this view allocates zero additional memory beyond storing references to the original containers.

Template Parameters
ContainersTypes of containers being zipped.
See also
stl_zip() Factory function
Author
Leandro Rabindranath León

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

Member Typedef Documentation

◆ const_iterator

template<typename... Containers>
using Aleph::StlZipView< Containers >::const_iterator = iterator

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

◆ iterator

template<typename... Containers>
using Aleph::StlZipView< Containers >::iterator = StlZipIterator<std::decay_t<Containers>...>

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

◆ value_type

template<typename... Containers>
using Aleph::StlZipView< Containers >::value_type = typename iterator::value_type

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

Constructor & Destructor Documentation

◆ StlZipView()

template<typename... Containers>
constexpr Aleph::StlZipView< Containers >::StlZipView ( const Containers &...  cs)
inlineexplicitconstexpr

Construct view from containers.

Parameters
csReferences to containers to zip.

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

Member Function Documentation

◆ begin()

template<typename... Containers>
constexpr iterator Aleph::StlZipView< Containers >::begin ( ) const
inlineconstexpr

Get iterator to beginning.

Returns
Iterator positioned at first tuple.

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

References Aleph::StlZipView< Containers >::containers_, and Aleph::maps().

Referenced by Aleph::StlZipView< Containers >::empty(), and Aleph::StlZipView< Containers >::size().

◆ empty()

template<typename... Containers>
constexpr bool Aleph::StlZipView< Containers >::empty ( ) const
inlineconstexpr

Check if view is empty.

Returns
true if any container is empty.

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

References Aleph::StlZipView< Containers >::begin(), Aleph::StlZipIterator< Containers >::has_curr(), and Aleph::maps().

◆ end()

template<typename... Containers>
constexpr iterator Aleph::StlZipView< Containers >::end ( ) const
inlineconstexpr

Get iterator to end.

Returns
Past-the-end iterator.

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

References Aleph::StlZipView< Containers >::containers_, and Aleph::maps().

◆ size()

template<typename... Containers>
size_t Aleph::StlZipView< Containers >::size ( ) const
inline

Get number of tuples (minimum size of all containers).

Returns
Number of tuples that would be produced.
Note
This iterates through all elements - O(n) complexity.

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

References Aleph::StlZipView< Containers >::begin(), Aleph::count(), and Aleph::StlZipIterator< Containers >::has_curr().

Member Data Documentation

◆ containers_

template<typename... Containers>
std::tuple<const std::decay_t<Containers> &...> Aleph::StlZipView< Containers >::containers_
private

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