proxygen
folly::gen::detail::Min< Selector, Comparer > Class Template Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::Min< Selector, Comparer >:
folly::gen::Operator< Min< Selector, Comparer > > folly::gen::FBounded< Self >

Public Member Functions

 Min ()=default
 
 Min (Selector selector)
 
 Min (Selector selector, Comparer comparer)
 
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Key = typename std::decay<invoke_result_t<Selector, Value>>::type>
Optional< StorageType > compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::Operator< Min< Selector, Comparer > >
ResultGen compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Private Member Functions

template<typename T >
const TasConst (const T &t) const
 

Private Attributes

Selector selector_
 
Comparer comparer_
 

Additional Inherited Members

- Protected Member Functions inherited from folly::gen::Operator< Min< Selector, Comparer > >
 Operator ()=default
 
 Operator (Operator &&) noexcept=default
 
 Operator (const Operator &)=default
 
Operatoroperator= (Operator &&) noexcept=default
 
Operatoroperator= (const Operator &)=default
 

Detailed Description

template<class Selector, class Comparer>
class folly::gen::detail::Min< Selector, Comparer >

Min - For a value which minimizes a key, where the key is determined by a given selector, and compared by given comparer.

This type is usually used through the singletone 'min' or through the helper functions 'minBy' and 'maxBy'.

auto oldest = from(people) | minBy([](Person& p) { return p.dateOfBirth; });

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

Constructor & Destructor Documentation

template<class Selector , class Comparer >
folly::gen::detail::Min< Selector, Comparer >::Min ( )
default
template<class Selector , class Comparer >
folly::gen::detail::Min< Selector, Comparer >::Min ( Selector  selector)
inlineexplicit

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

2225 : selector_(std::move(selector)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class Selector , class Comparer >
folly::gen::detail::Min< Selector, Comparer >::Min ( Selector  selector,
Comparer  comparer 
)
inline

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

References testing::Key(), type, and testing::Value().

2228  : selector_(std::move(selector)), comparer_(std::move(comparer)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Function Documentation

template<class Selector , class Comparer >
template<typename T >
const T& folly::gen::detail::Min< Selector, Comparer >::asConst ( const T t) const
inlineprivate

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

References folly::pushmi::detail::t.

2218  {
2219  return t;
2220  }
template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Key = typename std::decay<invoke_result_t<Selector, Value>>::type>
Optional<StorageType> folly::gen::detail::Min< Selector, Comparer >::compose ( const GenImpl< Value, Source > &  source) const
inline

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

References folly::Optional< Value >::get_pointer(), min, folly::gen::move, v, and testing::Value().

2235  {
2236  static_assert(
2237  !Source::infinite,
2238  "Calling min or max on an infinite source will cause "
2239  "an infinite loop.");
2240  Optional<StorageType> min;
2241  Optional<Key> minKey;
2242  source | [&](Value v) {
2243  Key key = selector_(asConst(v)); // so that selector_ cannot mutate v
2244  if (auto lastKey = minKey.get_pointer()) {
2245  if (!comparer_(key, *lastKey)) {
2246  return;
2247  }
2248  }
2249  minKey = std::move(key);
2250  min = std::forward<Value>(v);
2251  };
2252  return min;
2253  }
auto v
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
internal::KeyMatcher< M > Key(M inner_matcher)
constexpr detail::Min< Identity, Less > min
Definition: Base-inl.h:2559
const T & asConst(const T &t) const
Definition: Base-inl.h:2218
bool Value(const T &value, M matcher)

Member Data Documentation

template<class Selector , class Comparer >
Comparer folly::gen::detail::Min< Selector, Comparer >::comparer_
private

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

template<class Selector , class Comparer >
Selector folly::gen::detail::Min< Selector, Comparer >::selector_
private

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


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