66 template<
class F,
class...
T>
67 using noReferenceCond =
typename std::enable_if<
"Function can't return a reference" && !(std::is_reference<
typename std::result_of<
F(
T...)>
::type>::value)>::
type;
72 template<
class F,
class Cond = noReferenceCond<F>>
73 auto Map(
F func,
unsigned nTimes) -> std::vector<
typename std::result_of<
F()>
::type>;
74 template<
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
77 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
78 auto Map(
F func, std::initializer_list<T> args) -> std::vector<
typename std::result_of<
F(
T)>
::type>;
80 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
81 auto Map(
F func, std::vector<T> &args) -> std::vector<
typename std::result_of<
F(
T)>
::type>;
87 template<
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
90 template<
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
91 auto MapReduce(
F func, std::initializer_list<T> args,
R redfunc) ->
typename std::result_of<
F(
T)>
::type;
93 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
96 template<
class T>
T*
Reduce(
const std::vector<T*> &mergeObjs);
101 return *
static_cast<subc*
>(
this);
110template<
class subc>
template<
class F,
class Cond>
113 return Derived().Map(func, nTimes);
120template<
class subc>
template<
class F,
class INTEGER,
class Cond>
123 return Derived().Map(func, args);
130template<
class subc>
template<
class F,
class T,
class Cond>
133 std::vector<T> vargs(std::move(args));
134 const auto &reslist =
Map(func, vargs);
144template<
class subc>
template<
class F,
class T,
class Cond>
147 return Derived().Map(func, args);
156template<
class subc>
template<
class F,
class INTEGER,
class R,
class Cond>
159 std::vector<INTEGER> vargs(args.size());
160 std::copy(args.begin(), args.end(), vargs.begin());
161 return Derived().MapReduce(func, vargs, redfunc);
164template<
class subc>
template<
class F,
class T,
class R,
class Cond>
167 std::vector<T> vargs(std::move(args));
168 return Derived().MapReduce(func, vargs, redfunc);
171template<
class subc>
template<
class F,
class T,
class Cond>
174 return Derived().Reduce(
Map(func, args));
180template<
class subc>
template<
class T>
184 for(
unsigned i =1; i<mergeObjs.size(); i++){
188 auto retHist =
dynamic_cast<T*
>((mergeObjs.front())->Clone());
189 if (retHist) retHist->Merge(&
l);
#define R(a, b, c, d, e, f, g, h, i)
This class defines an interface to execute the same task multiple times in parallel,...
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute func (with no arguments) nTimes in parallel.
auto Map(F func, ROOT::TSeq< INTEGER > args) -> std::vector< typename std::result_of< F(INTEGER)>::type >
Execute func in parallel, taking an element of a sequence as argument.
auto Map(F func, std::vector< T > &args) -> std::vector< typename std::result_of< F(T)>::type >
Execute func in parallel, taking an element of an std::vector as argument.
T * MapReduce(F func, std::vector< T * > &args)
typename std::enable_if<"Function can't return a reference" &&!(std::is_reference< typename std::result_of< F(T...)>::type >::value)>::type noReferenceCond
auto MapReduce(F func, ROOT::TSeq< INTEGER > args, R redfunc) -> typename std::result_of< F(INTEGER)>::type
This method behaves just like Map, but an additional redfunc function must be provided.
T * Reduce(const std::vector< T * > &mergeObjs)
"Reduce" an std::vector into a single object by using the object's Merge
A pseudo container class which is a generator of indices.
auto Map(const RVec< T > &v, F &&f) -> RVec< decltype(f(v[0]))>
Create new collection applying a callable to the elements of the input collection.
Namespace for new ROOT classes and functions.