hpx/parallel/algorithms/generate.hpp#

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter, typename F>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type generate(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)#

Assign each element in range [first, last) a value generated by the given function object f. Executed according to the policy.

The assignments in the parallel generate 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 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 distance(first, last) invocations of f and assignments.

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.

  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a 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.

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

  • 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.

Returns

The generate algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise.

template<typename FwdIter, typename F>
FwdIter generate(FwdIter first, FwdIter last, F &&f)#

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

Note

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

Template Parameters
  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a 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.

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

  • 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.

Returns

The generate algorithm returns a FwdIter.

template<typename ExPolicy, typename FwdIter, typename Size, typename F>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type 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

    Ret fun();
    
    The type Ret must be such that an object of type OutputIt can be dereferenced and assigned a value of type Ret.

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 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

    Ret fun();
    
    The type Ret must be such that an object of type OutputIt can be dereferenced and assigned a value of type Ret.

Returns

The generate_n algorithm returns a FwdIter. generate_n algorithm returns iterator one past the last element assigned if count>0, first otherwise.