hpx::generate_n#
Defined in header hpx/algorithm.hpp.
See Public API for a list of names and headers that are part of the public HPX API.
See also:
-
template<typename ExPolicy, typename FwdIter, typename Size, typename F>
hpx::parallel::util::detail::algorithm_result_t<ExPolicy, FwdIter> hpx::generate_n(ExPolicy &&policy, FwdIter first, Size count, F &&f)# Assigns each element in range [first, first+) a value generated by the given function object f. Executed according to the policy.
The assignments in the parallel generate_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
The assignments in the parallel generate_n algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
Note
Complexity: Exactly count invocations of f and assignments, for count > 0.
- Template Parameters:
ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
Size – The type of a non-negative integral value specifying the number of items to iterate over.
FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
F – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires F to meet the requirements of CopyConstructible.
- Parameters:
policy – The execution policy to use for the scheduling of the iterations.
first – Refers to the beginning of the sequence of elements the algorithm will be applied to.
count – Refers to the number of elements in the sequence the algorithm will be applied to.
f – Refers to the generator function object that will be called. The signature of the function should be equivalent to
The type Ret must be such that an object of type OutputIt can be dereferenced and assigned a value of type Ret.Ret fun();
- Returns:
The generate_n algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. generate_n algorithm returns iterator one past the last element assigned if count>0, first otherwise.
-
template<typename FwdIter, typename Size, typename F>
FwdIter hpx::generate_n(FwdIter first, Size count, F &&f)# Assigns each element in range [first, first+) a value generated by the given function object f.
Note
Complexity: Exactly count invocations of f and assignments, for count > 0.
- Template Parameters:
Size – The type of a non-negative integral value specifying the number of items to iterate over.
FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
F – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires F to meet the requirements of CopyConstructible.
- Parameters:
first – Refers to the beginning of the sequence of elements the algorithm will be applied to.
count – Refers to the number of elements in the sequence the algorithm will be applied to.
f – Refers to the generator function object that will be called. The signature of the function should be equivalent to
The type Ret must be such that an object of type OutputIt can be dereferenced and assigned a value of type Ret.Ret fun();
- Returns:
The generate_n algorithm returns a FwdIter. generate_n algorithm returns iterator one past the last element assigned if count>0, first otherwise.