4#include "Stroika/Foundation/Containers/Sequence.h"
7namespace Stroika::Foundation::Traversal {
14 template <
typename IN_T,
typename OUT_T>
15 Iterable<OUT_T> DirectPushMapEngine::Map (
const Iterable<IN_T>& from,
const function<OUT_T (IN_T)>& do2Each)
17 Containers::Sequence<OUT_T> result;
18 for (
const IN_T& i : from) {
20 result.Append (do2Each (i));
24 template <
typename IN_T,
typename OUT_T>
25 OUT_T DirectPushMapEngine::Reduce (
const Iterable<IN_T>& from,
const function<OUT_T (IN_T, OUT_T)>& do2Each, OUT_T memo)
28 for (
const IN_T& i : from) {
29 result = do2Each (i, result);
33 template <
typename IN_OUT_T>
34 Iterable<IN_OUT_T> DirectPushMapEngine::Filter (
const Iterable<IN_OUT_T>& from,
const function<
bool (IN_OUT_T)>& includeTest)
36 Containers::Sequence<IN_OUT_T> result;
37 for (
const IN_OUT_T& i : from) {
38 if (includeTest (i)) {
44 template <
typename IN_OUT_T>
45 optional<IN_OUT_T> DirectPushMapEngine::Find (
const Iterable<IN_OUT_T>& from,
const function<
bool (IN_OUT_T)>& thatPassesThisTest)
47 for (
const IN_OUT_T& i : from) {
48 if (thatPassesThisTest (i)) {
60 template <
typename T,
typename MAPPER_ENGINE>
61 inline FunctionalApplicationContext<T, MAPPER_ENGINE>::FunctionalApplicationContext (Iterable<T> i, MAPPER_ENGINE m)
66 template <
typename T,
typename MAPPER_ENGINE>
67 template <
typename OUT_T>
72 template <
typename T,
typename MAPPER_ENGINE>
73 template <
typename OUT_T>
78 template <
typename T,
typename MAPPER_ENGINE>
79 template <
typename INOUT_T>
85 template <
typename T,
typename MAPPER_ENGINE>
86 template <
typename INOUT_T>
87 optional<INOUT_T> FunctionalApplicationContext<T, MAPPER_ENGINE>::Find (
const function<
bool (INOUT_T)>& that)
89 return fMappingEngine_.Find (inherited{*
this}, that);
OUT_T Reduce(const function< OUT_T(T, OUT_T)> &do2Each, OUT_T memo=OUT_T())
FunctionalApplicationContext< OUT_T, MAPPER_ENGINE > Map(const function< OUT_T(T)> &do2Each)
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.