proxygen
folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result > Class Template Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >:
folly::gen::GenImpl< StorageType &&, Generator< Value, Source, StorageType, Result > > folly::gen::FBounded< Self >

Public Member Functions

 Generator (Source source, Selector selector, Comparer comparer)
 
VectorType operator| (const Collect< VectorType > &) const
 
VectorType operator| (const CollectTemplate< std::vector > &) const
 
template<class Body >
void foreach (Body &&body) const
 
template<class Handler >
bool apply (Handler &&handler) const
 
- Public Member Functions inherited from folly::gen::GenImpl< StorageType &&, Generator< Value, Source, StorageType, Result > >
bool apply (Handler &&handler) const
 
void foreach (Body &&body) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Static Public Attributes

static constexpr bool infinite = false
 
- Static Public Attributes inherited from folly::gen::GenImpl< StorageType &&, Generator< Value, Source, StorageType, Result > >
static constexpr bool infinite
 

Private Types

typedef std::vector< StorageTypeVectorType
 

Private Member Functions

VectorType asVector () const
 

Private Attributes

Source source_
 
Selector selector_
 
Comparer comparer_
 

Additional Inherited Members

- Public Types inherited from folly::gen::GenImpl< StorageType &&, Generator< Value, Source, StorageType, Result > >
typedef StorageType && ValueType
 
typedef std::decay< StorageType && >::type StorageType
 
- Protected Member Functions inherited from folly::gen::GenImpl< StorageType &&, Generator< Value, Source, StorageType, Result > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class Selector, class Comparer>
template<class Value, class Source, class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
class folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >

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

Member Typedef Documentation

template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
typedef std::vector<StorageType> folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::VectorType
private

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

Constructor & Destructor Documentation

template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::Generator ( Source  source,
Selector  selector,
Comparer  comparer 
)
inline

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

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

Member Function Documentation

template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
template<class Handler >
bool folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::apply ( Handler &&  handler) const
inline

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

References a, b, handler(), and folly::gen::move.

1097  {
1098  auto comparer = [&](const StorageType& a, const StorageType& b) {
1099  // swapped for minHeap
1100  return comparer_(selector_(b), selector_(a));
1101  };
1102  auto heap = source_ | as<VectorType>();
1103  std::make_heap(heap.begin(), heap.end(), comparer);
1104  while (!heap.empty()) {
1105  std::pop_heap(heap.begin(), heap.end(), comparer);
1106  if (!handler(std::move(heap.back()))) {
1107  return false;
1108  }
1109  heap.pop_back();
1110  }
1111  return true;
1112  }
char b
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void handler(int, siginfo_t *, void *)
char a
template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
VectorType folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::asVector ( ) const
inlineprivate

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

References a, b, and folly::gen::move.

1066  {
1067  auto comparer = [&](const StorageType& a, const StorageType& b) {
1068  return comparer_(selector_(a), selector_(b));
1069  };
1070  auto vals = source_ | as<VectorType>();
1071  std::sort(vals.begin(), vals.end(), comparer);
1072  return std::move(vals);
1073  }
char b
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
char a
template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
template<class Body >
void folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::foreach ( Body &&  body) const
inline

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

References folly::gen::move, and value.

1090  {
1091  for (auto& value : asVector()) {
1092  body(std::move(value));
1093  }
1094  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
VectorType folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::operator| ( const Collect< VectorType > &  ) const
inline

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

1081  {
1082  return asVector();
1083  }
template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
VectorType folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::operator| ( const CollectTemplate< std::vector > &  ) const
inline

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

1085  {
1086  return asVector();
1087  }

Member Data Documentation

template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
Comparer folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::comparer_
private

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

template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
constexpr bool folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::infinite = false
static

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

template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
Selector folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::selector_
private

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

template<class Selector , class Comparer >
template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class Result = invoke_result_t<Selector, Value>>
Source folly::gen::detail::Order< Selector, Comparer >::Generator< Value, Source, StorageType, Result >::source_
private

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


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