hpx/parallel/container_algorithms/generate.hpp#

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

namespace hpx
namespace ranges

Functions

template<typename ExPolicy, typename Rng, typename F>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::traits::range_iterator_t<Rng>> generate(ExPolicy &&policy, Rng &&rng, F &&f)#

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

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.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range 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.

  • rng – Refers to 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 replace_if algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. It returns last.

template<typename ExPolicy, typename Iter, typename Sent, typename F>
hpx::parallel::util::detail::algorithm_result_t<ExPolicy, Iter> generate(ExPolicy &&policy, Iter first, Sent last, F &&f)#

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

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.

  • Iter – The type of the source begin iterator used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Sent – The type of the source end iterator 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.

  • 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 replace_if algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. It returns last.

template<typename Rng, typename F>
hpx::traits::range_iterator_t<Rng> generate(Rng &&rng, 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
  • Rng – The type of the source range used (deduced). The iterators extracted from this range 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
  • rng – Refers to 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 replace_if algorithm returns last.

template<typename Iter, typename Sent, typename F>
Iter generate(Iter first, Sent 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
  • Iter – The type of the source begin iterator used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Sent – The type of the source end iterator 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.

  • 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 replace_if algorithm returns last.

template<typename ExPolicy, typename FwdIter, typename Size, typename F>
hpx::parallel::util::detail::algorithm_result_t<ExPolicy, FwdIter> generate_n(ExPolicy &&policy, FwdIter first, Size count, F &&f)#

Assigns each element in range [first, first+count) a value generated by the given function object g.

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.

  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Size – The type of the argument specifying the number of elements to apply f to.

  • 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 replace_if algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. It returns last.

template<typename FwdIter, typename Size, typename F>
FwdIter generate_n(FwdIter first, Size count, F &&f)#

Assigns each element in range [first, first+count) a value generated by the given function object g.

Note

Complexity: Exactly count invocations of f and assignments, for count > 0.

Template Parameters
  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Size – The type of the argument specifying the number of elements to apply f to.

  • 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 replace_if algorithm returns last.