|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
CRTP Mixin providing functional programming operations. More...
#include <ah-dry-mixin.H>
Public Member Functions | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &operation) const -> decltype(self()) |
| Apply an operation to each element (read-only). | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &operation) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &&operation=Operation()) const -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &&operation=Operation()) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires CallableWith<Operation &, Type &> | |
| auto | mutable_for_each (Operation &operation) -> decltype(self()) |
| Apply an operation to each element (mutable). | |
| template<class Operation > requires CallableWith<Operation &, Type &> | |
| auto | mutable_for_each (Operation &&operation=Operation()) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | all (Operation &operation) const |
| Test if all elements satisfy a predicate. | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | all (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | forall (Operation &operation) const |
| Alias for all(). | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | forall (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| bool | exists (Operation &operation) const |
| Test if any element satisfies a predicate. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| bool | exists (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Container< concepts_detail::map_result_t< R, Operation &, Type > > | maps (Operation &operation) const |
| Container< concepts_detail::map_result_t< R, Operation &, Type > > | maps (Operation &&operation=Operation()) const |
| template<typename Acc = Type> | |
| Acc | foldl (const Acc &init, std::function< Acc(const Acc &, const Type &)> operation) const |
| Left fold (reduce) with initial value. | |
| template<typename Acc = Type> | |
| Acc | fold_left (std::function< Acc(const Acc &, const Type &)> operation, const Acc &init) const |
| Left fold with operation first (alternative signature). | |
| template<class Operation > requires requires(Type &acc, Operation &op, const Type &item) { acc = op(acc, item); } | |
| Type | fold (const Type &init, Operation &operation) const |
| Simple fold with same type for accumulator and elements. | |
| template<class Operation > requires requires(Type &acc, Operation &op, const Type &item) { acc = op(acc, item); } | |
| Type | fold (const Type &init, Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< Type > | filter (Operation &operation) const |
| Filter elements by a predicate. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< Type > | filter (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< std::tuple< Type, size_t > > | pfilter (Operation &operation) const |
| Filter with position information. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< std::tuple< Type, size_t > > | pfilter (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::pair< DynList< Type >, DynList< Type > > | partition (Operation &op) const |
| Partition elements by a predicate. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::pair< DynList< Type >, DynList< Type > > | partition (Operation &&op=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::tuple< DynList< Type >, DynList< Type > > | tpartition (Operation &op) const |
| Partition returning tuple instead of pair. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::tuple< DynList< Type >, DynList< Type > > | tpartition (Operation &&op=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| size_t | length () const noexcept |
| Count the number of elements. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | rev () const |
| Create a reversed copy. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | take (const size_t n) const |
| Take the first n elements. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | drop (const size_t n) const |
| Skip the first n elements. | |
| Type | sum (const Type &init=Type{}) const |
| Compute the sum of all elements. | |
| Type | product (const Type &init) const |
| Compute the product of all elements. | |
| const Type * | min () const |
| Find the minimum element. | |
| const Type * | max () const |
| Find the maximum element. | |
| template<class Compare > requires PredicateWith<Compare &, const Type &, const Type &> | |
| const Type * | min_by (Compare cmp) const |
| Find the minimum element using a custom comparator. | |
| template<class Compare > requires PredicateWith<Compare &, const Type &, const Type &> | |
| const Type * | max_by (Compare cmp) const |
| Find the maximum element using a custom comparator. | |
| bool | has_value (const Type &val) const |
| Check if container has a value. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| bool | none (Predicate &pred) const |
| Check if no element satisfies a predicate. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| bool | none (Predicate &&pred) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| size_t | count_if (Predicate pred) const |
| Count elements satisfying a predicate. | |
| const Type * | first () const |
| Get the first element. | |
| Type | first_or (const Type &default_val) const |
| Get the first element or a default value. | |
| const Type * | last () const |
| Get the last element. | |
| Type | last_or (const Type &default_val) const |
| Get the last element or a default value. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< std::pair< size_t, Type > > | enumerate () const |
| Enumerate elements with their indices. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| size_t | find_index (Predicate pred) const |
| Find the index of the first element satisfying a predicate. | |
| size_t | index_of (const Type &val) const |
| Find the index of a specific value. | |
| template<template< typename > class Container = Aleph::DynList> requires requires(Type a, Type b) { { a == b } -> std::convertible_to<bool>; } | |
| Container< Type > | unique () const |
| Remove consecutive duplicate elements. | |
| template<template< typename > class Container = Aleph::DynList, class EqPred > requires PredicateWith<EqPred &, const Type &, const Type &> | |
| Container< Type > | unique_by (EqPred eq) const |
| Remove consecutive duplicates using a custom equality predicate. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | intersperse (const Type &sep) const |
| Intersperse a separator between elements. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Container< Type > > | chunk (size_t n) const |
| Split into chunks of fixed size. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Container< Type > > | sliding (size_t size, size_t step=1) const |
| Create sliding windows of fixed size. | |
| std::vector< Type > | to_vector () const |
| Convert to std::vector. | |
| template<typename DynListType = DynList<Type>> | |
| DynListType | to_dynlist () const |
| Convert container to DynList. | |
| template<typename StringType = std::string> requires requires(Type a) { std::to_string(a); } | |
| StringType | join (const StringType &sep=StringType{", "}) const |
| Join elements into a string with separator. | |
| std::string | join_str (const std::string &sep=", ") const |
| Join string elements with separator. | |
| template<class Other , template< typename > class Container = Aleph::DynList> | |
| Container< std::pair< Type, typename Other::Item_Type > > | zip_with (const Other &other) const |
| Zip with another container. | |
Public Attributes | |
| template<typename R = void, template< typename > class Container = Aleph::DynList, class Operation > requires (Container<concepts_detail::map_result_t<R, Operation &, Type>> &l, Operation &op, const Type &item) | |
| and { l.append(std::invoke(op, item)) | |
| Transform elements using a mapping function. | |
Protected Member Functions | |
| const Derived & | self () const noexcept |
| Derived & | self () noexcept |
CRTP Mixin providing functional programming operations.
This mixin adds functional programming methods to containers:
| Derived | The derived container class (CRTP pattern). |
| Type | The element type stored in the container. |
traverse() method (typically via TraverseMixin)for_each() method (provided by this mixin, but needs traverse)Definition at line 503 of file ah-dry-mixin.H.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 651 of file ah-dry-mixin.H.
|
inline |
Test if all elements satisfy a predicate.
Returns true if the predicate returns true for every element. Returns true for empty containers (vacuous truth).
| Operation | Callable with signature bool(const Type&). |
| operation | Predicate to test. |
Definition at line 640 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self().
Referenced by Aleph::FunctionalMixin< Derived, Type >::sliding(), TEST(), TEST(), and TEST().
|
inline |
Split into chunks of fixed size.
| n | Chunk size. |
Definition at line 1715 of file ah-dry-mixin.H.
References Aleph::count(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Count elements satisfying a predicate.
| Predicate | Predicate type. |
| pred | Predicate function. |
Definition at line 1395 of file ah-dry-mixin.H.
References Aleph::count(), Aleph::FunctionalMixin< Derived, Type >::for_each(), pred, and Aleph::Type.
|
inline |
Skip the first n elements.
| n | Number of elements to skip. |
Definition at line 1112 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
Referenced by TEST().
|
inline |
Enumerate elements with their indices.
Definition at line 1518 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 711 of file ah-dry-mixin.H.
|
inline |
Test if any element satisfies a predicate.
Returns true if the predicate returns true for at least one element. Returns false for empty containers.
| Operation | Callable with signature bool(const Type&). |
| operation | Predicate to test. |
Definition at line 700 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
Referenced by Aleph::FunctionalMixin< Derived, Type >::none(), Aleph::FunctionalMixin< Derived, Type >::none(), TEST(), and TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 903 of file ah-dry-mixin.H.
|
inline |
Filter elements by a predicate.
Creates a new list containing only elements for which the predicate returns true.
| Operation | Callable with signature bool(const Type&). |
| operation | Predicate function. |
Definition at line 889 of file ah-dry-mixin.H.
References Aleph::DynList< T >::append(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Find the index of the first element satisfying a predicate.
| Predicate | Predicate type. |
| pred | Predicate function. |
end() in the STL and as find_index() of the ah-dry.H containers.Definition at line 1548 of file ah-dry-mixin.H.
References pred, Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
|
inline |
Get the first element.
Definition at line 1423 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
Referenced by demo_linear_system(), demo_matrix_vector_mult(), demo_string_indexed_vector(), Aleph::FunctionalMixin< Derived, Type >::first_or(), Aleph::FunctionalMixin< Derived, Type >::intersperse(), Aleph::FunctionalMixin< Derived, Type >::join_str(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Get the first element or a default value.
| default_val | Value to return if container is empty. |
Definition at line 1448 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::first().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 863 of file ah-dry-mixin.H.
References Aleph::init.
|
inline |
Simple fold with same type for accumulator and elements.
Simplified version of foldl() where accumulator has same type as elements.
| Operation | Binary operation type. |
| init | Initial value. |
| operation | Binary operation. |
Definition at line 850 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), Aleph::init, and Aleph::Type.
|
inline |
Left fold with operation first (alternative signature).
Definition at line 833 of file ah-dry-mixin.H.
References Aleph::init.
|
inline |
Left fold (reduce) with initial value.
Combines all elements using a binary operation, starting from an initial value. Computes: op(...op(op(init, x1), x2)..., xn).
| Acc | Accumulator type (default: same as element Type). |
| init | Initial value for the accumulator. |
| operation | Binary operation: (accumulator, element) -> new_accumulator. |
Definition at line 819 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), Aleph::init, and Aleph::Type.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 573 of file ah-dry-mixin.H.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 565 of file ah-dry-mixin.H.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 552 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
|
inline |
Apply an operation to each element (read-only).
Iterates through all elements, calling the operation on each. Unlike traverse(), always visits all elements (cannot stop early).
| Operation | Callable with signature void(const Type&). |
| operation | The operation to apply. |
Definition at line 539 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
Referenced by Aleph::FunctionalMixin< Derived, Type >::chunk(), Aleph::FunctionalMixin< Derived, Type >::count_if(), Aleph::FunctionalMixin< Derived, Type >::enumerate(), Aleph::FunctionalMixin< Derived, Type >::filter(), Aleph::FunctionalMixin< Derived, Type >::fold(), Aleph::FunctionalMixin< Derived, Type >::foldl(), Aleph::FunctionalMixin< Derived, Type >::intersperse(), Aleph::FunctionalMixin< Derived, Type >::join_str(), Aleph::FunctionalMixin< Derived, Type >::last(), Aleph::FunctionalMixin< Derived, Type >::length(), Aleph::FunctionalMixin< Derived, Type >::maps(), Aleph::FunctionalMixin< Derived, Type >::max_by(), Aleph::FunctionalMixin< Derived, Type >::min_by(), Aleph::outer_product(), Aleph::FunctionalMixin< Derived, Type >::partition(), Aleph::FunctionalMixin< Derived, Type >::pfilter(), Aleph::FunctionalMixin< Derived, Type >::rev(), Aleph::Matrix< Trow, Tcol, NumType >::set_vector_as_col(), Aleph::Matrix< Trow, Tcol, NumType >::set_vector_as_row(), Aleph::FunctionalMixin< Derived, Type >::sliding(), Aleph::Gen_Polynomial< Coefficient >::sturm_sign_changes(), TEST(), TEST(), Aleph::FunctionalMixin< Derived, Type >::to_dynlist(), Aleph::FunctionalMixin< Derived, Type >::to_vector(), Aleph::FunctionalMixin< Derived, Type >::tpartition(), and Aleph::FunctionalMixin< Derived, Type >::unique_by().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 675 of file ah-dry-mixin.H.
|
inline |
|
inline |
Check if container has a value.
| val | Value to search for. |
has_value() to avoid conflicts with contains() in tree/hash containers which have O(log n) or O(1) implementations.Definition at line 1335 of file ah-dry-mixin.H.
|
inline |
Find the index of a specific value.
| val | Value to search for. |
Definition at line 1579 of file ah-dry-mixin.H.
|
inline |
Intersperse a separator between elements.
| sep | Separator to insert between each pair of elements. |
Definition at line 1681 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::first(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
|
inline |
Join elements into a string with separator.
| sep | Separator string (default: ", "). |
Definition at line 1869 of file ah-dry-mixin.H.
|
inline |
Join string elements with separator.
| sep | Separator string (default: ", "). |
Definition at line 1898 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::first(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
|
inline |
Get the last element.
Definition at line 1467 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by Aleph::FunctionalMixin< Derived, Type >::last_or(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Get the last element or a default value.
| default_val | Value to return if container is empty. |
Definition at line 1491 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::last().
|
inlinenoexcept |
Count the number of elements.
Definition at line 1024 of file ah-dry-mixin.H.
References Aleph::count(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
|
inline |
Definition at line 783 of file ah-dry-mixin.H.
|
inline |
Definition at line 758 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::and, Aleph::DynList< T >::append(), Aleph::FunctionalMixin< Derived, Type >::for_each(), l, and Aleph::Type.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Find the maximum element.
Definition at line 1236 of file ah-dry-mixin.H.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Find the maximum element using a custom comparator.
| Compare | Comparator type. |
| cmp | Comparator function (returns true if first < second). |
Definition at line 1299 of file ah-dry-mixin.H.
References cmp(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by TEST().
|
inline |
Find the minimum element.
Definition at line 1206 of file ah-dry-mixin.H.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Find the minimum element using a custom comparator.
| Compare | Comparator type. |
| cmp | Comparator function (returns true if first < second). |
Definition at line 1269 of file ah-dry-mixin.H.
References cmp(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 608 of file ah-dry-mixin.H.
|
inline |
Apply an operation to each element (mutable).
Like for_each() but allows modifying elements.
| Operation | Callable with signature void(Type&). |
| operation | The operation to apply (can modify elements). |
Definition at line 595 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
Referenced by TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1373 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::exists(), and pred.
|
inline |
Check if no element satisfies a predicate.
| Predicate | Predicate type. |
| pred | Predicate function. |
Definition at line 1365 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::exists(), and pred.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 980 of file ah-dry-mixin.H.
|
inline |
Partition elements by a predicate.
Splits the container into two lists: elements satisfying the predicate go into first, others go into second.
| Operation | Callable with signature bool(const Type&). |
| op | Predicate function. |
Definition at line 964 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 941 of file ah-dry-mixin.H.
|
inline |
Filter with position information.
Like filter(), but returns tuples of (element, index) for matching elements.
| Operation | Callable with signature bool(const Type&). |
| operation | Predicate function. |
Definition at line 925 of file ah-dry-mixin.H.
References Aleph::DynList< T >::append(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
|
inline |
Compute the product of all elements.
| init | Initial value (default: Type{1} for numeric types). |
Definition at line 1177 of file ah-dry-mixin.H.
|
inline |
Create a reversed copy.
Definition at line 1050 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by TEST().
|
inlineprotectednoexcept |
Definition at line 506 of file ah-dry-mixin.H.
Referenced by Aleph::FunctionalMixin< Derived, Type >::all(), Aleph::FunctionalMixin< Derived, Type >::drop(), Aleph::FunctionalMixin< Derived, Type >::exists(), Aleph::FunctionalMixin< Derived, Type >::find_index(), Aleph::FunctionalMixin< Derived, Type >::first(), Aleph::FunctionalMixin< Derived, Type >::for_each(), Aleph::FunctionalMixin< Derived, Type >::for_each(), Aleph::FunctionalMixin< Derived, Type >::mutable_for_each(), Aleph::FunctionalMixin< Derived, Type >::take(), Aleph::FunctionalMixin< Derived, Type >::to_vector(), and Aleph::FunctionalMixin< Derived, Type >::zip_with().
|
inlineprotectednoexcept |
Definition at line 511 of file ah-dry-mixin.H.
|
inline |
Create sliding windows of fixed size.
| size | Window size. |
| step | Step between windows (default: 1). |
Definition at line 1759 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::all(), Aleph::FunctionalMixin< Derived, Type >::and, Aleph::FunctionalMixin< Derived, Type >::for_each(), Aleph::size(), and Aleph::Type.
|
inline |
Compute the sum of all elements.
| init | Initial value (default: Type{}). |
Definition at line 1147 of file ah-dry-mixin.H.
|
inline |
Take the first n elements.
| n | Maximum number of elements to take. |
Definition at line 1081 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
Referenced by TEST().
|
inline |
Convert container to DynList.
Creates a DynList containing all elements in traversal order.
| DynListType | DynList type (default: DynList<Type>). |
Definition at line 1841 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
|
inline |
Convert to std::vector.
Definition at line 1810 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::for_each(), Aleph::FunctionalMixin< Derived, Type >::self(), and Aleph::Type.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1006 of file ah-dry-mixin.H.
|
inline |
Partition returning tuple instead of pair.
Definition at line 990 of file ah-dry-mixin.H.
References Aleph::DynList< T >::append(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
|
inline |
Remove consecutive duplicate elements.
Definition at line 1612 of file ah-dry-mixin.H.
|
inline |
Remove consecutive duplicates using a custom equality predicate.
| Container | Result container type (default: DynList). |
| EqPred | Equality predicate type. |
| eq | Predicate that returns true if two elements are equal. |
Definition at line 1650 of file ah-dry-mixin.H.
References Aleph::eq(), Aleph::FunctionalMixin< Derived, Type >::for_each(), and Aleph::Type.
Referenced by TEST().
|
inline |
Zip with another container.
| Other | The other container type. |
| Container | Result container type (default: DynList). |
| other | The container to zip with. |
Definition at line 1937 of file ah-dry-mixin.H.
References Aleph::FunctionalMixin< Derived, Type >::and, and Aleph::FunctionalMixin< Derived, Type >::self().
| Aleph::FunctionalMixin< Derived, Type >::and { l.append(std::invoke(op, item)) |
Transform elements using a mapping function.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Creates a new container with each element transformed by the operation. This is the classic "map" operation from functional programming.
| R | Item type of the result, or void (the default) to take the type that operation returns, without references and const. |
| Container | Result container type (default: DynList). |
| Operation | Callable with signature R(const Type&), or a pointer to member; without operation, each item is converted to R, or copied if R is not given. |
| operation | Transformation function. |
Definition at line 755 of file ah-dry-mixin.H.
Referenced by Aleph::FunctionalMixin< Derived, Type >::maps(), Aleph::FunctionalMixin< Derived, Type >::sliding(), and Aleph::FunctionalMixin< Derived, Type >::zip_with().