HPX - High Performance ParalleX

PrevUpHomeNext

Function template generate

hpx::parallel::v1::generate

Synopsis

// In header: <hpx/parallel/algorithms/generate.hpp>


template<typename ExPolicy, typename FwdIter, typename F> 
  unspecified generate(ExPolicy && policy, FwdIter first, FwdIter last, 
                       F && f);

Description

Assign each element in range [first, last) a value generated by the given function object f

[Note] Note

Complexity: Exactly distance(first, last) invocations of f and assignments.

The assignments in the parallel generate algorithm invoked with an execution policy object of type sequential_execution_policy execute in sequential order in the calling thread.

The assignments in the parallel generate algorithm invoked with an execution policy object of type parallel_execution_policy or parallel_task_execution_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Parameters:

f

generator function that will be called. signature of function should be equivalent to the following:

Ret fun();


The type Ret must be such that an object of type FwdIter can be dereferenced and assigned a value of type Ret.

first

Refers to the beginning of the sequence of elements the algorithm will be applied to.

last

Refers to the end of the sequence of elements the algorithm will be applied to.

policy

The execution policy to use for the scheduling of the iterations.

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.

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.

FwdIter

The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.

Returns:

The replace_if algorithm returns a hpx::future<void> if the execution policy is of type sequential_task_execution_policy or parallel_task_execution_policy and returns void otherwise.


PrevUpHomeNext