|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Lazy iterator that traverses multiple STL containers in lockstep. More...
#include <ah-stl-zip.H>
Classes | |
| struct | end_tag |
| Construct end iterator (all at end). More... | |
Public Types | |
| using | iterator_category = std::input_iterator_tag |
| using | difference_type = std::ptrdiff_t |
| using | IteratorTuple = std::tuple< std::pair< typename std::decay_t< Containers >::const_iterator, typename std::decay_t< Containers >::const_iterator >... > |
| using | value_type = std::tuple< typename std::decay_t< Containers >::value_type... > |
| using | reference = std::tuple< const typename std::decay_t< Containers >::value_type &... > |
| using | pointer = void |
Public Member Functions | |
| constexpr | StlZipIterator (const Containers &... cs) |
| Construct iterator from containers. | |
| constexpr | StlZipIterator (const Containers &... cs, end_tag) |
| constexpr bool | has_curr () const noexcept |
| Check if iterator has current element. | |
| constexpr bool | completed () const noexcept |
| Check if all iterators have completed. | |
| constexpr auto | get_curr () const |
| Get current tuple of elements. | |
| constexpr void | next () noexcept |
| Advance all iterators. | |
| constexpr auto | operator* () const |
| Dereference operator for range-based for. | |
| constexpr StlZipIterator & | operator++ () noexcept |
| Pre-increment operator. | |
| constexpr StlZipIterator | operator++ (int) noexcept |
| Post-increment operator. | |
| constexpr bool | operator== (const StlZipIterator &other) const noexcept |
| Equality comparison. | |
| constexpr bool | operator!= (const StlZipIterator &other) const noexcept |
| Inequality comparison. | |
Static Public Attributes | |
| static constexpr size_t | num_containers = sizeof...(Containers) |
| Number of containers being zipped. | |
Private Member Functions | |
| template<size_t... Is> | |
| constexpr bool | has_curr_impl (std::index_sequence< Is... >) const noexcept |
| template<size_t... Is> | |
| constexpr auto | deref_impl (std::index_sequence< Is... >) const |
| template<size_t... Is> | |
| constexpr void | advance_impl (std::index_sequence< Is... >) noexcept |
| template<size_t... Is> | |
| constexpr bool | completed_impl (std::index_sequence< Is... >) const noexcept |
Private Attributes | |
| IteratorTuple | iters_ |
Lazy iterator that traverses multiple STL containers in lockstep.
This iterator allows synchronized iteration over multiple STL containers without allocating any additional memory. It produces tuples of references to elements at each position.
The iterator satisfies the InputIterator concept and can be used with range-based for loops and STL algorithms.
| Containers | Parameter pack of container types. |
Definition at line 141 of file ah-stl-zip.H.
| using Aleph::StlZipIterator< Containers >::difference_type = std::ptrdiff_t |
Definition at line 146 of file ah-stl-zip.H.
| using Aleph::StlZipIterator< Containers >::iterator_category = std::input_iterator_tag |
Definition at line 145 of file ah-stl-zip.H.
| using Aleph::StlZipIterator< Containers >::IteratorTuple = std::tuple< std::pair<typename std::decay_t<Containers>::const_iterator, typename std::decay_t<Containers>::const_iterator>...> |
Definition at line 149 of file ah-stl-zip.H.
| using Aleph::StlZipIterator< Containers >::pointer = void |
Definition at line 160 of file ah-stl-zip.H.
| using Aleph::StlZipIterator< Containers >::reference = std::tuple< const typename std::decay_t<Containers>::value_type &...> |
Definition at line 157 of file ah-stl-zip.H.
| using Aleph::StlZipIterator< Containers >::value_type = std::tuple< typename std::decay_t<Containers>::value_type...> |
Definition at line 154 of file ah-stl-zip.H.
|
inlineexplicitconstexpr |
Construct iterator from containers.
| cs | References to containers to zip. |
Definition at line 202 of file ah-stl-zip.H.
|
inlineconstexpr |
Definition at line 213 of file ah-stl-zip.H.
|
inlineconstexprprivatenoexcept |
Definition at line 181 of file ah-stl-zip.H.
References Aleph::stl_zip_detail::advance_all(), and Aleph::StlZipIterator< Containers >::iters_.
Referenced by Aleph::StlZipIterator< Containers >::next().
|
inlineconstexprnoexcept |
Check if all iterators have completed.
Useful to verify equal-length containers after iteration.
true if all underlying iterators are at their end. Definition at line 231 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::completed_impl().
|
inlineconstexprprivatenoexcept |
Definition at line 188 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::iters_, and Aleph::maps().
Referenced by Aleph::StlZipIterator< Containers >::completed().
|
inlineconstexprprivate |
Definition at line 174 of file ah-stl-zip.H.
References Aleph::stl_zip_detail::deref_all(), and Aleph::StlZipIterator< Containers >::iters_.
Referenced by Aleph::StlZipIterator< Containers >::get_curr().
|
inlineconstexpr |
Get current tuple of elements.
Definition at line 241 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::deref_impl().
Referenced by Aleph::StlZipIterator< Containers >::operator*(), Aleph::stl_zip_find_last(), Aleph::stl_zip_last(), and Aleph::stl_zip_take_while().
|
inlineconstexprnoexcept |
Check if iterator has current element.
true if all underlying iterators are valid. Definition at line 220 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::has_curr_impl().
Referenced by Aleph::StlZipView< Containers >::empty(), Aleph::StlZipIterator< Containers >::operator==(), and Aleph::StlZipView< Containers >::size().
|
inlineconstexprprivatenoexcept |
Definition at line 167 of file ah-stl-zip.H.
References Aleph::stl_zip_detail::all_valid(), and Aleph::StlZipIterator< Containers >::iters_.
Referenced by Aleph::StlZipIterator< Containers >::has_curr().
|
inlineconstexprnoexcept |
Advance all iterators.
Definition at line 250 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::advance_impl().
Referenced by Aleph::StlZipIterator< Containers >::operator++(), and Aleph::StlZipIterator< Containers >::operator++().
|
inlineconstexprnoexcept |
|
inlineconstexpr |
Dereference operator for range-based for.
Definition at line 261 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::get_curr().
|
inlineconstexprnoexcept |
Pre-increment operator.
Definition at line 270 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::next().
|
inlineconstexprnoexcept |
Post-increment operator.
Definition at line 280 of file ah-stl-zip.H.
References Aleph::maps(), and Aleph::StlZipIterator< Containers >::next().
|
inlineconstexprnoexcept |
Equality comparison.
Two iterators are equal if both have no current element.
Definition at line 291 of file ah-stl-zip.H.
References Aleph::StlZipIterator< Containers >::has_curr(), and Aleph::maps().
|
private |
Definition at line 163 of file ah-stl-zip.H.
Referenced by Aleph::StlZipIterator< Containers >::advance_impl(), Aleph::StlZipIterator< Containers >::completed_impl(), Aleph::StlZipIterator< Containers >::deref_impl(), and Aleph::StlZipIterator< Containers >::has_curr_impl().
|
staticconstexpr |
Number of containers being zipped.
Definition at line 196 of file ah-stl-zip.H.