|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Functional-style utilities (map/filter/fold), zip utilities, ranges adapters, and parallel variants. More...
Files | |
| file | ah-generator.H |
Lazy sequence type (Aleph::Generator<T>) built on C++20 coroutines. | |
| file | ah-parallel.H |
| Parallel functional programming operations using ThreadPool. | |
| file | ah-ranges.H |
| C++20 Ranges support and adaptors for Aleph-w containers. | |
| file | ah-stl-functional.H |
| Functional programming utilities for C++ Standard Library containers. | |
| file | ah-uni-functional.H |
| Unified functional programming utilities for both STL and Aleph containers. | |
| file | ah-zip-utils.H |
| Unified zip operations for both STL and Aleph containers. | |
| file | ah-zip.H |
| Zip iterators and functional operations for multiple containers. | |
Classes | |
| class | Aleph::Generator< T > |
Lazy, single-pass sequence of T values produced by a coroutine. More... | |
| struct | Aleph::Generator< T >::promise_type |
The promise type the compiler instantiates for a coroutine returning Generator<T>. More... | |
| class | Aleph::Generator< T >::iterator |
| Single-pass input iterator over the yielded sequence. More... | |
Functional-style utilities (map/filter/fold), zip utilities, ranges adapters, and parallel variants.
This module covers two related layers:
maps(), filter(), foldl()) via CRTP mixins.Many Aleph-w containers provide functional operations as member functions because they inherit from the CRTP mixin FunctionalMixin (see ah-dry-mixin.H).
In practice, this means that if a container provides a suitable traverse() method (directly or via TraverseMixin), it automatically gets methods such as:
for_each(...)maps<NewT>(...)filter(...)foldl(init, ...)all(...), exists(...)partition(...), take(n), drop(n), rev(), length()See tpl_dynSetTree.H.
The containers that inherit the CRTP mixin FunctionalMethods (see ah-dry.H): the lists, arrays, stacks, queues, heaps, sets and maps, provide a static build() that builds a container from its items:
C::build(a, b, c) builds the same container as C{a, b, c}: each item goes, in argument order, through the append() of the container, so its rules apply. A stack ends with the last item on top, a queue with the first item at its front, and a set or a map keeps the first of two equal keys. Unlike the braces, the items are forwarded: an rvalue is moved, so move-only types can be stored, and an item may have any type implicitly convertible to the item type. Being a named function rather than a constructor, Array<int>::build(10) is always the one-element array {10}; a capacity is reserved with Array<int>::create_reserved(10).
A class derived from a container (DynSetAvlTree, DynMapRbTree, MapOLhash, ...) builds itself rather than its base. A class of your own that derives from a container declares that build() with the macro Derived_Build(Name). The free function build_container<C>(items...) remains for any type with append().
BitArray inherits from FunctionalMixin, so it also supports the same family of member functions. See bitArray.H.
Graphs expose functional-style helpers, but they are generally specialized to node/arc traversal rather than being treated as a simple sequence container.
Common patterns include:
for_each_node, for_each_arc).none_node, count_nodes, etc.).nodes_map, arcs_map).See tpl_graph.H and graph-dry.H.