proxygen
folly::gen::detail::FoldLeft< Seed, Fold > Class Template Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::FoldLeft< Seed, Fold >:
folly::gen::Operator< FoldLeft< Seed, Fold > > folly::gen::FBounded< Self >

Public Member Functions

 FoldLeft ()=default
 
 FoldLeft (Seed seed, Fold fold)
 
template<class Source , class Value >
Seed compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::Operator< FoldLeft< Seed, Fold > >
ResultGen compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Private Attributes

Seed seed_
 
Fold fold_
 

Additional Inherited Members

- Protected Member Functions inherited from folly::gen::Operator< FoldLeft< Seed, Fold > >
 Operator ()=default
 
 Operator (Operator &&) noexcept=default
 
 Operator (const Operator &)=default
 
Operatoroperator= (Operator &&) noexcept=default
 
Operatoroperator= (const Operator &)=default
 

Detailed Description

template<class Seed, class Fold>
class folly::gen::detail::FoldLeft< Seed, Fold >

FoldLeft - Left-associative functional fold. For producing an aggregate value from a seed and a folder function. Useful for custom aggregators on a sequence.

This type is primarily used through the 'foldl' helper method, like:

double movingAverage = from(values) | foldl(0.0, [](double avg, double sample) { return sample * 0.1 + avg * 0.9; });

Definition at line 2004 of file Base-inl.h.

Constructor & Destructor Documentation

template<class Seed , class Fold >
folly::gen::detail::FoldLeft< Seed, Fold >::FoldLeft ( )
default
template<class Seed , class Fold >
folly::gen::detail::FoldLeft< Seed, Fold >::FoldLeft ( Seed  seed,
Fold  fold 
)
inline

Definition at line 2010 of file Base-inl.h.

static const int seed
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto fold(Fn &&, A &&a)

Member Function Documentation

template<class Seed , class Fold >
template<class Source , class Value >
Seed folly::gen::detail::FoldLeft< Seed, Fold >::compose ( const GenImpl< Value, Source > &  source) const
inline

Definition at line 2014 of file Base-inl.h.

References folly::gen::move, v, and testing::Value().

2014  {
2015  static_assert(!Source::infinite, "Cannot foldl infinite source");
2016  Seed accum = seed_;
2017  source | [&](Value v) {
2018  accum = fold_(std::move(accum), std::forward<Value>(v));
2019  };
2020  return accum;
2021  }
auto v
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
bool Value(const T &value, M matcher)

Member Data Documentation

template<class Seed , class Fold >
Fold folly::gen::detail::FoldLeft< Seed, Fold >::fold_
private

Definition at line 2006 of file Base-inl.h.

template<class Seed , class Fold >
Seed folly::gen::detail::FoldLeft< Seed, Fold >::seed_
private

Definition at line 2005 of file Base-inl.h.


The documentation for this class was generated from the following file: