Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-zip-utils.H File Reference

Unified zip operations for both STL and Aleph containers. More...

#include <type_traits>
#include <tuple>
#include <iterator>
#include <utility>
#include <optional>
#include <functional>
#include <htlist.H>
Include dependency graph for ah-zip-utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::uni_zip_detail::has_stl_iterator< T, typename >
 
struct  Aleph::uni_zip_detail::has_stl_iterator< T, std::void_t< decltype(std::declval< const T & >().begin()), decltype(std::declval< const T & >().end()), typename T::value_type > >
 
struct  Aleph::uni_zip_detail::has_aleph_iterator< T, typename >
 
struct  Aleph::uni_zip_detail::has_aleph_iterator< T, std::void_t< typename T::Iterator, typename T::Item_Type, decltype(std::declval< typename T::Iterator >().has_curr()), decltype(std::declval< typename T::Iterator >().get_curr()), decltype(std::declval< typename T::Iterator >().next_ne())> >
 
struct  Aleph::uni_zip_detail::container_value_type< T, std::enable_if_t< has_stl_iterator< T >::value > >
 
struct  Aleph::uni_zip_detail::container_value_type< T, std::enable_if_t< has_aleph_iterator< T >::value &&!has_stl_iterator< T >::value > >
 
class  Aleph::uni_zip_detail::StlIteratorWrapper< Container >
 Wrapper that provides uniform interface for STL iterators. More...
 
class  Aleph::uni_zip_detail::AlephIteratorWrapper< Container >
 Wrapper that provides uniform interface for Aleph iterators. More...
 
struct  Aleph::uni_zip_detail::IteratorWrapperSelector< Container, std::enable_if_t< has_stl_iterator< std::decay_t< Container > >::value > >
 
struct  Aleph::uni_zip_detail::IteratorWrapperSelector< Container, std::enable_if_t< has_aleph_iterator< std::decay_t< Container > >::value &&!has_stl_iterator< std::decay_t< Container > >::value > >
 
struct  Aleph::UniZipSentinel
 Sentinel type for UniZipIterator end comparison. More...
 
class  Aleph::UniZipIterator< Containers >
 Iterator that traverses multiple containers (STL or Aleph) in lockstep. More...
 
class  Aleph::UniZipView< Containers >
 Lazy view over multiple zipped containers (STL or Aleph). More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::uni_zip_detail
 
namespace  Aleph::uni_unzip_detail
 

Typedefs

template<typename T >
using Aleph::uni_zip_detail::container_value_t = typename container_value_type< std::decay_t< T > >::type
 
template<typename Container >
using Aleph::uni_zip_detail::iterator_wrapper_t = typename IteratorWrapperSelector< Container >::type
 

Functions

template<typename... Containers>
auto Aleph::uni_zip (const Containers &... cs)
 Create a lazy zip view over any combination of STL/Aleph containers.
 
template<typename... Containers>
auto Aleph::uni_zip_it (const Containers &... cs)
 Get a unified zip iterator.
 
template<typename Pred , typename... Containers>
bool Aleph::uni_zip_all (Pred &&pred, const Containers &... cs)
 Check if predicate holds for all zipped tuples.
 
template<typename Pred , typename... Containers>
bool Aleph::uni_zip_all_eq (Pred &&pred, const Containers &... cs)
 Check if all tuples satisfy predicate AND containers have equal length.
 
template<typename Pred , typename... Containers>
bool Aleph::uni_zip_exists (Pred &&pred, const Containers &... cs)
 Check if predicate holds for any zipped tuple.
 
template<typename Pred , typename... Containers>
bool Aleph::uni_zip_any (Pred &&pred, const Containers &... cs)
 Alias for uni_zip_exists.
 
template<typename Pred , typename... Containers>
bool Aleph::uni_zip_none (Pred &&pred, const Containers &... cs)
 Check if no tuple satisfies the predicate.
 
template<typename Op , typename... Containers>
void Aleph::uni_zip_for_each (Op &&op, const Containers &... cs)
 Apply operation to each zipped tuple.
 
template<typename Op , typename... Containers>
void Aleph::uni_zip_for_each_indexed (Op &&op, const Containers &... cs)
 Apply operation to each tuple with index.
 
template<typename T , typename Op , typename... Containers>
T Aleph::uni_zip_foldl (T init, Op &&op, const Containers &... cs)
 Left fold over zipped tuples.
 
template<typename T , typename Op , typename... Containers>
T Aleph::uni_zip_reduce (T init, Op &&op, const Containers &... cs)
 Alias for uni_zip_foldl.
 
template<typename Op , typename... Containers>
auto Aleph::uni_zip_map (Op &&op, const Containers &... cs)
 Map operation over zipped tuples.
 
template<typename Pred , typename... Containers>
auto Aleph::uni_zip_filter (Pred &&pred, const Containers &... cs)
 Filter zipped tuples by predicate.
 
template<typename Pred , typename... Containers>
auto Aleph::uni_zip_find_first (Pred &&pred, const Containers &... cs)
 Find first tuple satisfying predicate.
 
template<typename Pred , typename... Containers>
size_t Aleph::uni_zip_count (Pred &&pred, const Containers &... cs)
 Count tuples satisfying predicate.
 
template<typename... Containers>
size_t Aleph::uni_zip_length (const Containers &... cs)
 Get zip length (minimum of all container sizes).
 
template<typename... Containers>
bool Aleph::uni_zip_equal_length (const Containers &... cs)
 Check if all containers have equal length.
 
template<typename... Containers>
auto Aleph::uni_zip_nth (size_t n, const Containers &... cs)
 Get n-th tuple from zipped containers.
 
template<typename... Containers>
auto Aleph::uni_zip_take (size_t n, const Containers &... cs)
 Take first n tuples.
 
template<typename... Containers>
auto Aleph::uni_zip_drop (size_t n, const Containers &... cs)
 Skip first n tuples, return the rest.
 
template<typename Pred , typename... Containers>
auto Aleph::uni_zip_take_while (Pred &&pred, const Containers &... cs)
 Take tuples while predicate is true.
 
template<typename Pred , typename... Containers>
auto Aleph::uni_zip_drop_while (Pred &&pred, const Containers &... cs)
 Skip tuples while predicate is true, return the rest.
 
template<typename... Containers>
auto Aleph::uni_zip_first (const Containers &... cs)
 Get first tuple.
 
template<typename... Containers>
auto Aleph::uni_zip_last (const Containers &... cs)
 Get last tuple.
 
template<typename Pred , typename... Containers>
auto Aleph::uni_zip_partition (Pred &&pred, const Containers &... cs)
 Partition tuples by predicate.
 
template<typename... Containers>
auto Aleph::uni_zip_to_vector (const Containers &... cs)
 Materialize zipped tuples into a vector.
 
template<typename Pred , typename... Containers>
bool Aleph::uni_zip_traverse (Pred &&pred, const Containers &... cs)
 Traverse while predicate returns true.
 
template<typename Op , typename... Containers>
auto Aleph::uni_zip_mapi (Op &&op, const Containers &... cs)
 Map with index (mapi in ML).
 
template<typename Pred , typename... Containers>
auto Aleph::uni_zip_filteri (Pred &&pred, const Containers &... cs)
 Filter with index (filteri in ML).
 
template<typename T , typename Op , typename... Containers>
auto Aleph::uni_zip_scan_left (T init, Op &&op, const Containers &... cs)
 Scan left - fold with intermediate results.
 
template<typename Op , typename... Containers>
auto Aleph::uni_zip_find_mapi (Op &&op, const Containers &... cs)
 Find and map with index (find_mapi in ML).
 
template<typename Eq , typename... Containers>
bool Aleph::uni_zip_equal_by (Eq &&eq, const Containers &... cs)
 Check equality with custom comparator.
 
template<typename Tuple , typename... Containers>
bool Aleph::uni_zip_mem (const Tuple &target, const Containers &... cs)
 Check if a tuple exists in the zipped sequence (mem in ML).
 
template<typename Key , typename... Containers>
auto Aleph::uni_zip_assoc (const Key &key, const Containers &... cs)
 Find value associated with key in zipped pairs (assoc in ML).
 
template<typename... Containers>
auto Aleph::uni_zip_min (const Containers &... cs)
 Get minimum tuple.
 
template<typename... Containers>
auto Aleph::uni_zip_max (const Containers &... cs)
 Get maximum tuple.
 
template<typename... Containers>
auto Aleph::uni_zip_min_max (const Containers &... cs)
 Get both min and max in a single pass.
 
template<typename Container >
auto Aleph::uni_unzip (const Container &c)
 Unzip a container of pairs into two DynLists.
 
template<typename Tuple , size_t... Is>
auto Aleph::uni_unzip_detail::make_dynlist_tuple (std::index_sequence< Is... >)
 
template<typename Tuple , typename ResultTuple , size_t... Is>
void Aleph::uni_unzip_detail::append_tuple_elements (const Tuple &t, ResultTuple &result, std::index_sequence< Is... >)
 
template<typename Container >
auto Aleph::uni_unzip_tuple (const Container &c)
 Unzip a container of tuples into a tuple of DynLists.
 
template<typename... Containers>
auto Aleph::uni_zip_to_dynlist (const Containers &... cs)
 Materialize a zipped view into a DynList of tuples.
 

Variables

template<typename T >
constexpr bool Aleph::uni_zip_detail::is_supported_container_v
 

Detailed Description

Unified zip operations for both STL and Aleph containers.

This header provides zip operations that work seamlessly with:

  • STL containers: std::vector, std::list, std::set, etc.
  • Aleph containers: DynList, DynArray, DynSetTree, etc.
  • Mixed combinations: Zip a std::vector with a DynList

The implementation uses type traits to detect the container type and automatically adapts to the appropriate iterator interface.

Usage Examples:

#include <vector>
#include <ah-zip-utils.H>
#include <htlist.H>
std::vector<int> stl_vec = {1, 2, 3};
DynList<std::string> aleph_list = {"a", "b", "c"};
// Mix STL and Aleph containers!
for (auto [num, str] : uni_zip(stl_vec, aleph_list))
std::cout << num << ": " << str << "\n";
// All functional operations work
bool all_ok = uni_zip_all([](auto t) {
return std::get<0>(t) > 0;
}, stl_vec, aleph_list);
Unified zip operations for both STL and Aleph containers.
Singly linked list implementations with head-tail access.
auto uni_zip(const Containers &... cs)
Create a lazy zip view over any combination of STL/Aleph containers.
bool uni_zip_all(Pred &&pred, const Containers &... cs)
Check if predicate holds for all zipped tuples.
STL namespace.
Note
All zip operations stop at the shortest container.
Author
Leandro Rabindranath Leon

Definition in file ah-zip-utils.H.