# algorithms¶

The contents of this module can be included with the header hpx/modules/algorithms.hpp. These headers may be used by user-code but are not guaranteed stable (neither header location nor contents). You are using these at your own risk. If you wish to use non-public functionality from a module we strongly suggest only including the module header hpx/modules/algorithms.hpp, not the particular header in which the functionality you would like to use is defined. See Public API for a list of names that are part of the public HPX API.

namespace hpx
namespace traits
struct general_pointer_tag

Subclassed by hpx::traits::trivially_copyable_pointer_tag

template<typename Source, typename Dest, typename Enable = void>
struct pointer_category

Public Types

template<>
using type = general_pointer_tag
template<typename Source, typename Dest>
struct pointer_category<Source*, Dest*>

Public Types

template<>
using type = typename std::conditional::type
template<typename Iterator, typename Enable = void>
struct remove_const_iterator_value_type

Public Types

template<>
using type = Iterator
template<typename Iterator>
struct projected_iterator<Iterator, typename std::enable_if<is_segmented_iterator<Iterator>::value>::type>

Public Types

typedef segmented_iterator_traits<Iterator>::local_iterator local_iterator
typedef segmented_local_iterator_traits<local_iterator>::local_raw_iterator type
template<typename Iterator>
struct projected_iterator<Iterator, typename hpx::util::always_void<typename std::decay<Iterator>::type::proxy_type>::type>

Public Types

typedef std::decay<Iterator>::type::proxy_type type
namespace hpx
namespace parallel
namespace traits
template<typename Proj, typename Iter>
struct projected

Public Types

typedef std::decay<Proj>::type projector_type
typedef hpx::traits::projected_iterator<Iter>::type iterator_type
namespace traits
template<typename T, typename Enable = void>
struct projected_iterator

Public Types

typedef std::decay<T>::type type
template<typename Iterator>
struct projected_iterator<Iterator, typename hpx::util::always_void<typename std::decay<Iterator>::type::proxy_type>::type>

Public Types

typedef std::decay<Iterator>::type::proxy_type type
template<typename Iterator>
struct projected_iterator<Iterator, typename std::enable_if<is_segmented_iterator<Iterator>::value>::type>

Public Types

typedef segmented_iterator_traits<Iterator>::local_iterator local_iterator
typedef segmented_local_iterator_traits<local_iterator>::local_raw_iterator type
template<typename Proj, typename Rng>
struct projected_range<Proj, Rng, typename std::enable_if<hpx::traits::is_range<Rng>::value>::type>

Public Types

typedef std::decay<Proj>::type projector_type
typedef hpx::traits::range_iterator<Rng>::type iterator_type
namespace hpx
namespace parallel
namespace traits
template<typename Proj, typename Rng>
struct projected_range<Proj, Rng, typename std::enable_if<hpx::traits::is_range<Rng>::value>::type>

Public Types

typedef std::decay<Proj>::type projector_type
typedef hpx::traits::range_iterator<Rng>::type iterator_type
namespace hpx
namespace traits
template<typename Iterator, typename Enable = void>
struct segmented_iterator_traits

Public Types

typedef std::false_type is_segmented_iterator
template<typename Iterator, typename Enable = void>
struct segmented_local_iterator_traits

Public Types

typedef std::false_type is_segmented_local_iterator
typedef Iterator iterator
typedef Iterator local_iterator
typedef Iterator local_raw_iterator

Public Static Functions

static local_raw_iterator const &local(local_iterator const &it)
static local_iterator const &remote(local_raw_iterator const &it)
static local_raw_iterator local(local_iterator &&it)
static local_iterator remote(local_raw_iterator &&it)
namespace hpx
namespace lcos
namespace local

Functions

template<typename ExPolicy, typename F, typename ...Args, typename = typename std::enable_if<hpx::parallel::execution::is_async_execution_policy<ExPolicy>::value>::type>
std::vector<hpx::future<void>> define_spmd_block(ExPolicy &&policy, std::size_t num_images, F &&f, Args&&... args)
template<typename ExPolicy, typename F, typename ...Args, typename = typename std::enable_if<!hpx::is_async_execution_policy<ExPolicy>::value>::type>
void define_spmd_block(ExPolicy &&policy, std::size_t num_images, F &&f, Args&&... args)
template<typename F, typename ...Args>
void define_spmd_block(std::size_t num_images, F &&f, Args&&... args)
struct spmd_block
#include <spmd_block.hpp>

The class spmd_block defines an interface for launching multiple images while giving handles to each image to interact with the remaining images. The define_spmd_block function templates create multiple images of a user-defined function (or lambda) and launches them in a possibly separate thread. A temporary spmd block object is created and diffused to each image. The constraint for the function (or lambda) given to the define_spmd_block function is to accept a spmd_block as first parameter.

Public Functions

spmd_block(std::size_t num_images, std::size_t image_id, barrier_type &barrier, table_type &barriers, mutex_type &mtx)
spmd_block(spmd_block&&)
spmd_block(spmd_block const&)
spmd_block &operator=(spmd_block&&)
spmd_block &operator=(spmd_block const&)
std::size_t get_num_images() const
std::size_t this_image() const
void sync_all() const
void sync_images(std::set<std::size_t> const &images) const
void sync_images(std::vector<std::size_t> const &input_images) const
template<typename Iterator>
std::enable_if<traits::is_input_iterator<Iterator>::value>::type sync_images(Iterator begin, Iterator end) const
template<typename ...I>
std::enable_if<util::all_of<typename std::is_integral<I>::type...>::value>::type sync_images(I... i) const

Private Types

using barrier_type = hpx::lcos::local::barrier
using table_type = std::map<std::set<std::size_t>, std::shared_ptr<barrier_type>>
using mutex_type = hpx::lcos::local::mutex

Private Members

std::size_t num_images_
std::size_t image_id_
std::reference_wrapper<barrier_type> barrier_
std::reference_wrapper<table_type> barriers_
std::reference_wrapper<mutex_type> mtx_
namespace parallel

Typedefs

using spmd_block = hpx::lcos::local::spmd_block

The class spmd_block defines an interface for launching multiple images while giving handles to each image to interact with the remaining images. The define_spmd_block function templates create multiple images of a user-defined function (or lambda) and launches them in a possibly separate thread. A temporary spmd block object is created and diffused to each image. The constraint for the function (or lambda) given to the define_spmd_block function is to accept a spmd_block as first parameter.

Functions

template<typename ExPolicy, typename F, typename ...Args, typename = typename std::enable_if<hpx::parallel::execution::is_async_execution_policy<ExPolicy>::value>::type>
std::vector<hpx::future<void>> define_spmd_block(ExPolicy &&policy, std::size_t num_images, F &&f, Args&&... args)
template<typename ExPolicy, typename F, typename ...Args, typename = typename std::enable_if<!hpx::is_async_execution_policy<ExPolicy>::value>::type>
void define_spmd_block(ExPolicy &&policy, std::size_t num_images, F &&f, Args&&... args)
template<typename F, typename ...Args>
void define_spmd_block(std::size_t num_images, F &&f, Args&&... args)
namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename F>
util::detail::algorithm_result<ExPolicy>::type define_task_block(ExPolicy &&policy, F &&f)

Constructs a task_block, tr, using the given execution policy policy,and invokes the expression f(tr) on the user-provided object, f.

f have finished execution. A call to define_task_block may return on a different thread than that on which it was called.
Template Parameters
• ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the task block may be parallelized.

• F: The type of the user defined function to invoke inside the define_task_block (deduced). F shall be MoveConstructible.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• f: The user defined function to invoke inside the task block. Given an lvalue tr of type task_block, the expression, (void)f(tr), shall be well-formed.

Note

It is expected (but not mandated) that f will (directly or indirectly) call tr.run(callable_object).

Exceptions
• An: exception_list, as specified in Exception Handling.

template<typename F>
void define_task_block(F &&f)

Constructs a task_block, tr, and invokes the expression f(tr) on the user-provided object, f. This version uses parallel_policy for task scheduling.

f have finished execution. A call to define_task_block may return on a different thread than that on which it was called.
Template Parameters
• F: The type of the user defined function to invoke inside the define_task_block (deduced). F shall be MoveConstructible.

Parameters
• f: The user defined function to invoke inside the task block. Given an lvalue tr of type task_block, the expression, (void)f(tr), shall be well-formed.

Note

It is expected (but not mandated) that f will (directly or indirectly) call tr.run(callable_object).

Exceptions
• An: exception_list, as specified in Exception Handling.

template<typename ExPolicy, typename F>
util::detail::algorithm_result<ExPolicy>::type define_task_block_restore_thread(ExPolicy &&policy, F &&f)

Constructs a task_block, tr, and invokes the expression f(tr) on the user-provided object, f.

f have finished execution. A call to define_task_block_restore_thread always returns on the same thread as that on which it was called.
Template Parameters
• ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the task block may be parallelized.

• F: The type of the user defined function to invoke inside the define_task_block (deduced). F shall be MoveConstructible.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• f: The user defined function to invoke inside the define_task_block. Given an lvalue tr of type task_block, the expression, (void)f(tr), shall be well-formed.

Exceptions
• An: exception_list, as specified in Exception Handling.

Note

It is expected (but not mandated) that f will (directly or indirectly) call tr.run(callable_object).

template<typename F>
void define_task_block_restore_thread(F &&f)

Constructs a task_block, tr, and invokes the expression f(tr) on the user-provided object, f. This version uses parallel_policy for task scheduling.

f have finished execution. A call to define_task_block_restore_thread always returns on the same thread as that on which it was called.
Template Parameters
• F: The type of the user defined function to invoke inside the define_task_block (deduced). F shall be MoveConstructible.

Parameters
• f: The user defined function to invoke inside the define_task_block. Given an lvalue tr of type task_block, the expression, (void)f(tr), shall be well-formed.

Exceptions
• An: exception_list, as specified in Exception Handling.

Note

It is expected (but not mandated) that f will (directly or indirectly) call tr.run(callable_object).

namespace v2
template<typename ExPolicy = hpx::execution::parallel_policy>
class task_block

The class task_block defines an interface for forking and joining parallel tasks. The define_task_block and define_task_block_restore_thread function templates create an object of type task_block and pass a reference to that object to a user-provided callable object.

An object of class task_block cannot be constructed, destroyed, copied, or moved except by the implementation of the task region library. Taking the address of a task_block object via operator& or addressof is ill formed. The result of obtaining its address by any other means is unspecified.

enclosing” means the most recent invocation that has not yet completed. Code designated for execution in another thread by means other than the facilities in this section (e.g., using thread or async) are not enclosed in the task region and a

task_block passed to (or captured by) such code is not active within that code. Performing any operation on a task_block that is not active results in undefined behavior.

The task_block that is active before a specific call to the run member function is not active within the asynchronous function that invoked run. (The invoked function should not, therefore, capture the task_block from the surrounding block.)

Example:
tr.run([&] {
tr.run([] { f(); });                // Error: tr is not active
tr.run(f);                      // OK: inner tr is active
/// ...
});
});
/// ...
});


Template Parameters
• ExPolicy: The execution policy an instance of a task_block was created with. This defaults to parallel_policy.

Public Types

typedef ExPolicy execution_policy

Refers to the type of the execution policy used to create the task_block.

Public Functions

execution_policy const &get_execution_policy() const

Return the execution policy instance used to create this task_block

template<typename F, typename ...Ts>
void run(F &&f, Ts&&... ts)

Causes the expression f() to be invoked asynchronously. The invocation of f is permitted to run on an unspecified thread in an unordered fashion relative to the sequence of operations following the call to run(f) (the continuation), or indeterminately sequenced within the same thread as the continuation.

The call to run synchronizes with the invocation of f. The completion of f() synchronizes with the next invocation of wait on the same task_block or completion of the nearest enclosing task block (i.e., the define_task_block or define_task_block_restore_thread that created this task block).

Requires: F shall be MoveConstructible. The expression, (void)f(), shall be well-formed.

Precondition: this shall be the active task_block.

Postconditions: A call to run may return on a different thread than that on which it was called.

Note

The call to run is sequenced before the continuation as if run returns on the same thread. The invocation of the user-supplied callable object f may be immediate or may be delayed until compute resources are available. run might or might not return before invocation of f completes.

Exceptions

template<typename Executor, typename F, typename ...Ts>
void run(Executor &exec, F &&f, Ts&&... ts)

Causes the expression f() to be invoked asynchronously using the given executor. The invocation of f is permitted to run on an unspecified thread associated with the given executor and in an unordered fashion relative to the sequence of operations following the call to run(exec, f) (the continuation), or indeterminately sequenced within the same thread as the continuation.

The call to run synchronizes with the invocation of f. The completion of f() synchronizes with the next invocation of wait on the same task_block or completion of the nearest enclosing task block (i.e., the define_task_block or define_task_block_restore_thread that created this task block).

Requires: Executor shall be a type modeling the Executor concept. F shall be MoveConstructible. The expression, (void)f(), shall be well-formed.

Precondition: this shall be the active task_block.

Postconditions: A call to run may return on a different thread than that on which it was called.

Note

The call to run is sequenced before the continuation as if run returns on the same thread. The invocation of the user-supplied callable object f may be immediate or may be delayed until compute resources are available. run might or might not return before invocation of f completes.

Exceptions

void wait()

Precondition: this shall be the active task_block.

Postcondition: All tasks spawned by the nearest enclosing task region have finished. A call to wait may return on a different thread than that on which it was called.

Example:
tr.run([&]{ process(a, w, x); }); // Process a[w] through a[x]
if (y < x) tr.wait();   // Wait if overlap between [w, x) and [y, z)
process(a, y, z);       // Process a[y] through a[z]
});

Note

The call to wait is sequenced before the continuation as if wait returns on the same thread.

Exceptions

ExPolicy &policy()

Returns a reference to the execution policy used to construct this object.

Precondition: this shall be the active task_block.

ExPolicy const &policy() const

Returns a reference to the execution policy used to construct this object.

Precondition: this shall be the active task_block.

Private Members

mutex_type mtx_
std::vector<hpx::future<void>> tasks_
parallel::exception_list errors_
threads::thread_id_type id_
ExPolicy policy_
class task_canceled_exception : public exception

The class task_canceled_exception defines the type of objects thrown by task_block::run or task_block::wait if they detect that an exception is pending within the current parallel region.

Public Functions

task_canceled_exception()
namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type adjacent_difference(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)

Assigns each value in the range given by result its corresponding element in the range [first, last] and the one preceding it except *result, which is assigned *first

The difference operations in the parallel

adjacent_difference invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly (last - first) - 1 application of the binary operator and (last - first) 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.

• FwdIter1: The type of the source iterators used for the input range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the output range (deduced). This iterator type must meet the requirements of an forward iterator.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of the range the algorithm will be applied to.

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

• dest: Refers to the beginning of the sequence of elements the results will be assigned to.

The difference operations in the parallel adjacent_difference 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.

adjacent_find is available if the user decides to provide their algorithm their own binary predicate op.
Return

The adjacent_difference algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The adjacent_find algorithm returns an iterator to the last element in the output range.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Op>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type adjacent_difference(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op)

Assigns each value in the range given by result its corresponding element in the range [first, last] and the one preceding it except *result, which is assigned *first

The difference operations in the parallel

adjacent_difference invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly (last - first) - 1 application of the binary operator and (last - first) 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.

• FwdIter1: The type of the source iterators used for the input range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the output range (deduced). This iterator type must meet the requirements of an forward iterator.

• Op: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of adjacent_difference requires Op 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 of the range the algorithm will be applied to.

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

• dest: Refers to the beginning of the sequence of elements the results will be assigned to.

• op: The binary operator which returns the difference of elements. The signature should be equivalent to the following:

bool op(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 must be such that objects of type FwdIter1 can be dereferenced and then implicitly converted to the dereferenced type of dest.

The difference operations in the parallel adjacent_difference 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.

Return

The adjacent_difference algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The adjacent_find algorithm returns an iterator to the last element in the output range.

namespace hpx

Functions

template<typename FwdIter, typename Pred = detail::equal_to>
FwdIter adjacent_find(FwdIter first, FwdIter last, Pred &&pred = Pred())

Searches the range [first, last) for two consecutive identical elements.

Note

Complexity: Exactly the smaller of (result - first) + 1 and (last - first) - 1 application of the predicate where result is the value returned

Return

The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

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

• Pred: The type of an optional function/function object to use.

Parameters
• first: Refers to the beginning of the sequence of elements of the range the algorithm will be applied to.

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

• pred: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1 .

template<typename ExPolicy, typename FwdIter, typename Pred = detail::equal_to>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter>::type>::type adjacent_find(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred = Pred())

Searches the range [first, last) for two consecutive identical elements. This version uses the given binary predicate pred

The comparison operations in the parallel

adjacent_find invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly the smaller of (result - first) + 1 and (last - first) - 1 application of the predicate where result is the value returned

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 for the range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of the range the algorithm will be applied to.

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

• pred: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1 .

The comparison operations in the parallel adjacent_find 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.

adjacent_find is available if the user decides to provide their algorithm their own binary predicate pred.
Return

The adjacent_find algorithm returns a hpx::future<InIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns InIter otherwise. The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type none_of(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f, Proj &&proj = Proj())

Checks if unary predicate f returns true for no elements in the range [first, last).

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last - first applications of the predicate f

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 applies user-provided function objects.

• 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 none_of requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The application of function objects in parallel 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.

Return

The none_of algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The none_of algorithm returns true if the unary predicate f returns true for no elements in the range, false otherwise. It returns true if the range is empty.

template<typename ExPolicy, typename FwdIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type any_of(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f, Proj &&proj = Proj())

Checks if unary predicate f returns true for at least one element in the range [first, last).

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last - first applications of the predicate f

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 applies user-provided function objects.

• 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 any_of requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The application of function objects in parallel 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.

Return

The any_of algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The any_of algorithm returns true if the unary predicate f returns true for at least one element in the range, false otherwise. It returns false if the range is empty.

template<typename ExPolicy, typename FwdIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type all_of(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f, Proj &&proj = Proj())

Checks if unary predicate f returns true for all elements in the range [first, last).

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last - first applications of the predicate f

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 applies user-provided function objects.

• 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 all_of requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The application of function objects in parallel 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.

Return

The all_of algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The all_of algorithm returns true if the unary predicate f returns true for all elements in the range, false otherwise. It returns true if the range is empty.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::type copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)

Copies the elements in the range, defined by [first, last), to another range beginning at dest.

The assignments in the parallel

copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

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.

• dest: Refers to the beginning of the destination range.

The assignments in the parallel copy 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.

Return

The copy algorithm returns a hpx::future<FwdIter2> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2> otherwise. The copy algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::type copy_n(ExPolicy &&policy, FwdIter1 first, Size count, FwdIter2 dest)

Copies the elements in the range [first, first + count), starting from first and proceeding to first + count - 1., to another range beginning at dest.

The assignments in the parallel

copy_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

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 starting at first the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

The assignments in the parallel copy_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.

Return

The copy_n algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::type copy_if(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Pred &&pred)

Copies the elements in the range, defined by [first, last), to another range beginning at dest. Copies only the elements for which the predicate f returns true. The order of the elements that are not removed is preserved.

The assignments in the parallel

copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if 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.

• dest: Refers to the beginning of the destination range.

• pred: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

The assignments in the parallel copy_if 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.

Return

The copy_if algorithm returns a hpx::future<FwdIter2> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIterB, typename FwdIterE, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<FwdIterB>::difference_type>::type count(ExPolicy &&policy, FwdIterB first, FwdIterE last, T const &value, Proj &&proj = Proj())

Returns the number of elements in the range [first, last) satisfying a specific criteria. This version counts the elements that are equal to the given value.

The comparisons in the parallel

count algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first comparisons.

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

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

• FwdIterE: The type of the source end iterator used (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to search for (deduced).

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• value: The value to search for.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Note

The comparisons in the parallel count 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.

Return

The count algorithm returns a hpx::future<difference_type> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns difference_type otherwise (where difference_type is defined by std::iterator_traits<FwdIterB>::difference_type. The count algorithm returns the number of elements satisfying the given criteria.

template<typename ExPolicy, typename Iter, typename Sent, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<Iter>::difference_type>::type count_if(ExPolicy &&policy, Iter first, Sent last, F &&f, Proj &&proj = Proj())

Returns the number of elements in the range [first, last) satisfying a specific criteria. This version counts elements for which predicate f returns true.

Note

Complexity: Performs exactly last - first applications of the predicate.

Note

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

Note

The assignments in the parallel count_if 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.

Return

The count_if algorithm returns hpx::future<difference_type> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns difference_type otherwise (where difference_type is defined by std::iterator_traits<FwdIterB>::difference_type. The count algorithm returns the number of elements satisfying the given criteria.

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

• 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 count_if requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIterB can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter>
util::detail::algorithm_result<ExPolicy>::type destroy(ExPolicy &&policy, FwdIter first, FwdIter last)

Destroys objects of type typename iterator_traits<ForwardIt>::value_type in the range [first, last).

The operations in the parallel

destroy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first operations.

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.

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.

The operations in the parallel destroy 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.

Return

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

template<typename ExPolicy, typename FwdIter, typename Size>
util::detail::algorithm_result<ExPolicy, FwdIter>::type destroy_n(ExPolicy &&policy, FwdIter first, Size count)

Destroys objects of type typename iterator_traits<ForwardIt>::value_type in the range [first, first + count).

The operations in the parallel

destroy_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count operations, if count > 0, no assignments otherwise.

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 this algorithm to.

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 starting at first the algorithm will be applied to.

The operations in the parallel destroy_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.

Return

The destroy_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. The destroy_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, bool>::type equal(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred())

Returns true if the range [first1, last1) is equal to the range [first2, last2), and false otherwise.

The comparison operations in the parallel

equal algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most min(last1 - first1, last2 - first2) applications of the predicate f.

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of equal requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

The comparison operations in the parallel equal 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

The two ranges are considered equal if, for every iterator i in the range [first1,last1), *i equals *(first2 + (i - first1)). This overload of equal uses operator== to determine if two elements are equal.

Return

The equal algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The equal algorithm returns true if the elements in the two ranges are equal, otherwise it returns false. If the length of the range [first1, last1) does not equal the length of the range [first2, last2), it returns false.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, bool>::type equal(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, Pred &&op = Pred())

Returns true if the range [first1, last1) is equal to the range starting at first2, and false otherwise.

The comparison operations in the parallel

equal algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last1 - first1 applications of the predicate f.

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of equal requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

The comparison operations in the parallel equal 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

The two ranges are considered equal if, for every iterator i in the range [first1,last1), *i equals *(first2 + (i - first1)). This overload of equal uses operator== to determine if two elements are equal.

Return

The equal algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The equal algorithm returns true if the elements in the two ranges are equal, otherwise it returns false.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T, typename Op>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type exclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T init, Op &&op)

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, *first, …, *(first + (i - result) - 1)).

The reduce operations in the parallel

exclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

• Op: The type of the binary function object used for the reduction operation.

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.

• dest: Refers to the beginning of the destination range.

• init: The initial value for the generalized sum.

• op: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.

The reduce operations in the parallel exclusive_scan 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.

The difference between

exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum. If op is not mathematically associative, the behavior of inclusive_scan may be non-deterministic.
Return

The exclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The exclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:

• a1 when N is 1

• op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type exclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T init)

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(+, init, *first, …, *(first + (i - result) - 1))

The reduce operations in the parallel

exclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate std::plus<T>.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

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.

• dest: Refers to the beginning of the destination range.

• init: The initial value for the generalized sum.

The reduce operations in the parallel exclusive_scan 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.

The difference between

exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum.
Return

The exclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The exclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aN) is defined as:

• a1 when N is 1

• GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aK)

• GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, …, aN) where 1 < K+1 = M <= N.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter, typename T>
util::detail::algorithm_result<ExPolicy>::type fill(ExPolicy &&policy, FwdIter first, FwdIter last, T value)

Assigns the given value to the elements in the range [first, last).

The comparisons in the parallel

fill algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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 an forward iterator.

• T: The type of the value to be assigned (deduced).

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.

• value: The value to be assigned.

The comparisons in the parallel fill 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.

Return

The fill algorithm returns a hpx::future<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns difference_type otherwise (where difference_type is defined by void.

template<typename ExPolicy, typename FwdIter, typename Size, typename T>
util::detail::algorithm_result<ExPolicy, FwdIter>::type fill_n(ExPolicy &&policy, FwdIter first, Size count, T value)

Assigns the given value value to the first count elements in the range beginning at first if count > 0. Does nothing otherwise.

The comparisons in the parallel

fill_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count 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 output iterator.

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

• T: The type of the value to be assigned (deduced).

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 starting at first the algorithm will be applied to.

• value: The value to be assigned.

The comparisons in the parallel fill_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.

Return

The fill_n algorithm returns a hpx::future<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns difference_type otherwise (where difference_type is defined by void.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter, typename T>
util::detail::algorithm_result<ExPolicy, FwdIter>::type find(ExPolicy &&policy, FwdIter first, FwdIter last, T const &val)

Returns the first element in the range [first, last) that is equal to value

The comparison operations in the parallel

find algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last - first applications of the operator==().

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 for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to find (deduced).

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• val: the value to compare the elements to

The comparison operations in the parallel find 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.

Return

The find algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The find algorithm returns the first element in the range [first,last) that is equal to val. If no such element in the range of [first,last) is equal to val, then the algorithm returns last.

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

Returns the first element in the range [first, last) for which predicate f returns true

The comparison operations in the parallel

find_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last - first applications of the predicate.

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 for the first range (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 of the first range the algorithm will be applied to.

• last: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• f: The unary predicate which returns true for the required element. The signature of the predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type.

The comparison operations in the parallel find_if 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.

Return

The find_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. The find_if algorithm returns the first element in the range [first,last) that satisfies the predicate f. If no such element exists that satisfies the predicate f, the algorithm returns last.

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

Returns the first element in the range [first, last) for which predicate f returns false

The comparison operations in the parallel

find_if_not algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last - first applications of the predicate.

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 for the first range (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 of the first range the algorithm will be applied to.

• last: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• f: The unary predicate which returns false for the required element. The signature of the predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type.

The comparison operations in the parallel find_if_not 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.

Return

The find_if_not algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The find_if_not algorithm returns the first element in the range [first, last) that does not satisfy the predicate f. If no such element exists that does not satisfy the predicate f, the algorithm returns last.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter1>::type find_end(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred())

Returns the last subsequence of elements [first2, last2) found in the range [first, last) using the given predicate f to compare elements.

The comparison operations in the parallel

find_end algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: at most S*(N-S+1) comparisons where S = distance(first2, last2) and N = distance(first1, last1).

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of replace requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

• Proj: The type of an optional projection function. This defaults to util::projection_identity and is applied to the elements of type dereferenced FwdIter1 and dereferenced FwdIter2.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements the algorithm will be searching for.

• last2: Refers to the end of the sequence of elements of the algorithm will be searching for.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively.

• proj: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter1 and dereferenced FwdIter2 as a projection operation before the function f is invoked.

The comparison operations in the parallel find_end 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.

find_end is available if the user decides to provide the algorithm their own predicate f.
Return

The find_end algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The find_end algorithm returns an iterator to the beginning of the last subsequence [first2, last2) in range [first, last). If the length of the subsequence [first2, last2) is greater than the length of the range [first1, last1), last1 is returned. Additionally if the size of the subsequence is empty or no subsequence is found, last1 is also returned.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter1>::type find_first_of(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 s_first, FwdIter2 s_last, Pred &&op = Pred())

Searches the range [first, last) for any elements in the range [s_first, s_last). Uses binary predicate p to compare elements

The comparison operations in the parallel

find_first_of algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = distance(first, last).

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of equal requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

• Proj1: The type of an optional projection function. This defaults to util::projection_identity and is applied to the elements of type dereferenced FwdIter1.

• Proj2: The type of an optional projection function. This defaults to util::projection_identity and is applied to the elements of type dereferenced FwdIter2.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• s_first: Refers to the beginning of the sequence of elements the algorithm will be searching for.

• s_last: Refers to the end of the sequence of elements of the algorithm will be searching for.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively.

• proj1: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter1 as a projection operation before the function op is invoked.

• proj2: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter2 as a projection operation before the function op is invoked.

The comparison operations in the parallel find_first_of 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.

Return

The find_first_of algorithm returns a hpx::future<FwdIter1> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter1 otherwise. The find_first_of algorithm returns an iterator to the first element in the range [first, last) that is equal to an element from the range [s_first, s_last). If the length of the subsequence [s_first, s_last) is greater than the length of the range [first, last), last is returned. Additionally if the size of the subsequence is empty or no subsequence is found, last is also returned. This overload of find_end is available if the user decides to provide the algorithm their own predicate f.

namespace hpx

Functions

template<typename InIter, typename F>
F for_each(InIter first, InIter last, F &&f)

Applies f to the result of dereferencing every iterator in the range [first, last).

If

f returns a result, the result is ignored.
Note

Complexity: Applies f exactly last - first times.

If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.

Return

f.

Template Parameters
• InIter: The type of the source begin and end iterator used (deduced). This iterator type must meet the requirements of an input iterator.

• F: The type of the function/function object to use (deduced). F must meet requirements of MoveConstructible.

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

<ignored> pred(const Type &a);


The signature does not need to have const&. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

template<typename ExPolicy, typename FwdIter, typename F>
util::detail::algorithm_result<ExPolicy, void>::type for_each(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)

Applies f to the result of dereferencing every iterator in the range [first, last).

If

f returns a result, the result is ignored.
Note

Complexity: Applies f exactly last - first times.

If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.

Unlike its sequential form, the parallel overload of for_each does not return a copy of its Function parameter, since parallelization may not permit efficient state accumulation.

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
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 applies user-provided function objects.

• FwdIte: The type of the source begin and 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 for_each 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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

<ignored> pred(const Type &a);


The signature does not need to have const&. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

The application of function objects in parallel 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.

Return

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

template<typename InIter, typename Size, typename F>
InIter for_each_n(InIter first, Size count, F &&f)

Applies f to the result of dereferencing every iterator in the range [first, first + count), starting from first and proceeding to first + count - 1.

If

f returns a result, the result is ignored.
Note

Complexity: Applies f exactly count times.

If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.

Return

first + count for non-negative values of count and first for negative values.

Template Parameters
• InIter: The type of the source begin and end iterator used (deduced). This iterator type must meet the requirements of an input 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). F must meet requirements of MoveConstructible.

Parameters
• first: Refers to the beginning of the sequence of elements the algorithm will be applied to.

• count: Refers to the number of elements starting at first the algorithm will be applied to.

• f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

<ignored> pred(const Type &a);


The signature does not need to have const&. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

template<typename ExPolicy, typename FwdIter, typename Size, typename F>
util::detail::algorithm_result<ExPolicy, FwdIter>::type for_each_n(ExPolicy &&policy, FwdIter first, Size count, F &&f)

Applies f to the result of dereferencing every iterator in the range [first, first + count), starting from first and proceeding to first + count - 1.

If

f returns a result, the result is ignored.
Note

Complexity: Applies f exactly count times.

If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.

Unlike its sequential form, the parallel overload of for_each does not return a copy of its Function parameter, since parallelization may not permit efficient state accumulation.

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
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 applies user-provided function objects.

• 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 for_each 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 starting at first the algorithm will be applied to.

• f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

<ignored> pred(const Type &a);


The signature does not need to have const&. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

The application of function objects in parallel 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.

Return

The for_each_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. It returns first + count for non-negative values of count and first for negative values.

namespace hpx

Functions

template<typename I, typename ...Args>
void for_loop(typename std::decay<I>::type first, I last, Args&&... args)

The for_loop implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

The execution of for_loop without specifying an execution policy is equivalent to specifying hpx::execution::seq as the execution policy.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
Template Parameters
• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

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.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

template<typename ExPolicy, typename I, typename ...Args>
util::detail::algorithm_result<ExPolicy>::type for_loop(ExPolicy &&policy, typename std::decay<I>::type first, I last, Args&&... args)

The for_loop implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
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 applies user-provided function objects.

• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

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.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

Return

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

template<typename I, typename S, typename ...Args>
void for_loop_strided(typename std::decay<I>::type first, I last, S stride, Args&&... args)

The for_loop_strided implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

The execution of for_loop without specifying an execution policy is equivalent to specifying hpx::execution::seq as the execution policy.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
Template Parameters
• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• S: The type of the stride variable. This should be an integral type.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

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.

• stride: Refers to the stride of the iteration steps. This shall have non-zero value and shall be negative only if I has integral type or meets the requirements of a bidirectional iterator.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

template<typename ExPolicy, typename I, typename S, typename ...Args>
util::detail::algorithm_result<ExPolicy>::type for_loop_strided(ExPolicy &&policy, typename std::decay<I>::type first, I last, S stride, Args&&... args)

The for_loop_strided implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
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 applies user-provided function objects.

• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• S: The type of the stride variable. This should be an integral type.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

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.

• stride: Refers to the stride of the iteration steps. This shall have non-zero value and shall be negative only if I has integral type or meets the requirements of a bidirectional iterator.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

Return

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

template<typename I, typename Size, typename ...Args>
void for_loop_n(I first, Size size, Args&&... args)

The for_loop_n implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

The execution of for_loop_n without specifying an execution policy is equivalent to specifying hpx::execution::seq as the execution policy.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
Template Parameters
• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• Size: The type of a non-negative integral value specifying the number of items to iterate over.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

Parameters
• first: Refers to the beginning of the sequence of elements the algorithm will be applied to.

• size: Refers to the number of items the algorithm will be applied to.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

template<typename ExPolicy, typename I, typename Size, typename ...Args>
util::detail::algorithm_result<ExPolicy>::type for_loop_n(ExPolicy &&policy, I first, Size size, Args&&... args)

The for_loop_n implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
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 applies user-provided function objects.

• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• Size: The type of a non-negative integral value specifying the number of items to iterate over.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

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.

• size: Refers to the number of items the algorithm will be applied to.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

Return

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

template<typename I, typename Size, typename S, typename ...Args>
void for_loop_n_strided(I first, Size size, S stride, Args&&... args)

The for_loop_n_strided implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

The execution of for_loop without specifying an execution policy is equivalent to specifying hpx::execution::seq as the execution policy.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
Template Parameters
• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• Size: The type of a non-negative integral value specifying the number of items to iterate over.

• S: The type of the stride variable. This should be an integral type.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

Parameters
• first: Refers to the beginning of the sequence of elements the algorithm will be applied to.

• size: Refers to the number of items the algorithm will be applied to.

• stride: Refers to the stride of the iteration steps. This shall have non-zero value and shall be negative only if I has integral type or meets the requirements of a bidirectional iterator.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

template<typename ExPolicy, typename I, typename Size, typename S, typename ...Args>
util::detail::algorithm_result<ExPolicy>::type for_loop_n_strided(ExPolicy &&policy, I first, Size size, S stride, Args&&... args)

The for_loop_n_strided implements loop functionality over a range specified by integral or iterator bounds. For the iterator case, these algorithms resemble for_each from the Parallelism TS, but leave to the programmer when and if to dereference the iterator.

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
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 applies user-provided function objects.

• I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.

• Size: The type of a non-negative integral value specifying the number of items to iterate over.

• S: The type of the stride variable. This should be an integral type.

• Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.

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.

• size: Refers to the number of items the algorithm will be applied to.

• stride: Refers to the stride of the iteration steps. This shall have non-zero value and shall be negative only if I has integral type or meets the requirements of a bidirectional iterator.

• args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:

<ignored> pred(I const& a, ...);


The signature does not need to have const&. It will receive the current value of the iteration variable and one argument for each of the induction or reduction objects passed to the algorithms, representing their current values.

Effects: Applies f to each element in the input sequence, with additional arguments corresponding to the reductions and inductions in the args parameter pack. The length of the input sequence is last - first.

The first element in the input sequence is specified by first. Each subsequent element is generated by incrementing the previous element.

Along with an element from the input sequence, for each member of the

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note

As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.

Note

The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

If the pack member is an object returned by a call to a reduction function listed in section, then the additional argument is a reference to a view of that reduction object. If the pack member is an object returned by a call to induction, then the additional argument is the induction value for that induction object corresponding to the position of the application of f in the input sequence.

Complexity: Applies f exactly once for each element of the input sequence.

Remarks: If f returns a result, the result is ignored.

Return

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

namespace hpx
namespace parallel

Functions

template<typename T>
constexpr detail::induction_stride_helper<T> induction(T &&value, std::size_t stride)

The function template returns an induction object of unspecified type having a value type and encapsulating an initial value value of that type and, optionally, a stride.

For each element in the input range, a looping algorithm over input sequence S computes an induction value from an induction variable and ordinal position p within S by the formula i + p * stride if a stride was specified or i + p otherwise. This induction value is passed to the element access function.

If the value argument to induction is a non-const lvalue, then that lvalue becomes the live-out object for the returned induction object. For each induction object that has a live-out object, the looping algorithm assigns the value of i + n * stride to the live-out object upon return, where n is the number of elements in the input range.

Return

This returns an induction object with value type T, initial value value, and (if specified) stride stride. If T is an lvalue of non-const type, value is used as the live-out object for the induction object; otherwise there is no live-out object.

Template Parameters
• T: The value type to be used by the induction object.

Parameters
• value: [in] The initial value to use for the induction object

• stride: [in] The (optional) stride to use for the induction object (default: 1)

namespace hpx
namespace parallel

Functions

template<typename T, typename Op>
constexpr detail::reduction_helper<T, typename std::decay<Op>::type> reduction(T &var, T const &identity, Op &&combiner)

The function template returns a reduction object of unspecified type having a value type and encapsulating an identity value for the reduction, a combiner function object, and a live-out object from which the initial value is obtained and into which the final value is stored.

A parallel algorithm uses reduction objects by allocating an unspecified number of instances, called views, of the reduction’s value type. Each view is initialized with the reduction object’s identity value, except that the live-out object (which was initialized by the caller) comprises one of the views. The algorithm passes a reference to a view to each application of an element-access function, ensuring that no two concurrently-executing invocations share the same view. A view can be shared between two applications that do not execute concurrently, but initialization is performed only once per view.

Modifications to the view by the application of element access functions accumulate as partial results. At some point before the algorithm returns, the partial results are combined, two at a time, using the reduction object’s combiner operation until a single value remains, which is then assigned back to the live-out object.

T shall meet the requirements of CopyConstructible and MoveAssignable. The expression var = combiner(var, var) shall be well formed.

Template Parameters
• T: The value type to be used by the induction object.

• Op: The type of the binary function (object) used to perform the reduction operation.

Parameters
• var: [in,out] The life-out value to use for the reduction object. This will hold the reduced value after the algorithm is finished executing.

• identity: [in] The identity value to use for the reduction operation.

• combiner: [in] The binary function (object) used to perform a pairwise reduction on the elements.

Note

In order to produce useful results, modifications to the view should be limited to commutative operations closely related to the combiner operation. For example if the combiner is plus<T>, incrementing the view would be consistent with the combiner but doubling it or assigning to it would not.

Return

This returns a reduction object of unspecified type having a value type of T. When the return value is used by an algorithm, the reference to var is used as the live-out object, new views are initialized to a copy of identity, and views are combined by invoking the copy of combiner, passing it the two views to be combined.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter, typename F>
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

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

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.

Return

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

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

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.

Return

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.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::less>
util::detail::algorithm_result<ExPolicy, bool>::type::type includes(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred())

Returns true if every element from the sorted range [first2, last2) is found within the sorted range [first1, last1). Also returns true if [first2, last2) is empty. The version expects both ranges to be sorted with the user supplied binary predicate f.

The comparison operations in the parallel

includes algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

At most 2*(N1+N2-1) comparisons, where N1 = std::distance(first1, last1) and N2 = std::distance(first2, last2).

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of includes requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• op: The binary predicate which returns true if the elements should be treated as includes. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

The comparison operations in the parallel includes 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.

Return

The includes algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The includes algorithm returns true every element from the sorted range [first2, last2) is found within the sorted range [first1, last1). Also returns true if [first2, last2) is empty.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Op, typename T>
util::detail::algorithm_result<ExPolicy, FwdIter2>::type inclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op, T init)

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, init, *first, …, *(first + (i - result))).

The reduce operations in the parallel

inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

• Op: The type of the binary function object used for the reduction operation.

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.

• dest: Refers to the beginning of the destination range.

• init: The initial value for the generalized sum.

• op: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.

The reduce operations in the parallel inclusive_scan 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.

The difference between

exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum. If op is not mathematically associative, the behavior of inclusive_scan may be non-deterministic.
Return

The inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:

• a1 when N is 1

• op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Op>
util::detail::algorithm_result<ExPolicy, FwdIter2>::type inclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op)

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, *first, …, *(first + (i - result))).

The reduce operations in the parallel

inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• Op: The type of the binary function object used for the reduction operation.

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.

• dest: Refers to the beginning of the destination range.

• op: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.

The reduce operations in the parallel inclusive_scan 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.

The difference between

exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum.
Return

The inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aN) is defined as:

• a1 when N is 1

• GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK)

• GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, …, aN) where 1 < K+1 = M <= N.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type inclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)

Assigns through each iterator i in [result, result + (last - first)) the value of gENERALIZED_NONCOMMUTATIVE_SUM(+, *first, …, *(first + (i - result))).

The reduce operations in the parallel

inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

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.

• dest: Refers to the beginning of the destination range.

The reduce operations in the parallel inclusive_scan 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.

The difference between

exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum.
Return

The inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aN) is defined as:

• a1 when N is 1

• GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aK)

• GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, …, aN) where 1 < K+1 = M <= N.

namespace hpx

Functions

template<typename ExPolicy, typename RandIter, typename Comp = detail::less>
util::detail::algorithm_result<ExPolicy, bool>::type is_heap(ExPolicy &&policy, RandIter first, RandIter last, Comp &&comp = Comp())

Returns whether the range is max heap. That is, true if the range is max heap, false otherwise. The function uses the given comparison function object comp (defaults to using operator<()).

comp has to induce a strict weak ordering on the values.

Note

Complexity: Performs at most N applications of the comparison comp, at most 2 * N applications of the projection proj, where N = last - first.

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.

• RandIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• Comp: The type of the function/function object to use (deduced).

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.

• comp: comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator.

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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.

Return

The is_heap algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The is_heap algorithm returns whether the range is max heap. That is, true if the range is max heap, false otherwise.

template<typename ExPolicy, typename RandIter, typename Comp = detail::less>
util::detail::algorithm_result<ExPolicy, RandIter>::type is_heap_until(ExPolicy &&policy, RandIter first, RandIter last, Comp &&comp = Comp())

Returns the upper bound of the largest range beginning at first which is a max heap. That is, the last iterator it for which range [first, it) is a max heap. The function uses the given comparison function object comp (defaults to using operator<()).

comp has to induce a strict weak ordering on the values.

Note

Complexity: Performs at most N applications of the comparison comp, at most 2 * N applications of the projection proj, where N = last - first.

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.

• RandIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• Comp: The type of the function/function object to use (deduced).

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.

• comp: comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator.

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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.

Return

The is_heap_until algorithm returns a hpx::future<RandIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns RandIter otherwise. The is_heap_until algorithm returns the upper bound of the largest range beginning at first which is a max heap. That is, the last iterator it for which range [first, it) is a max heap.

namespace hpx

Functions

template<typename FwdIter, typename Pred>
bool is_partitioned(FwdIter first, FwdIter last, Pred &&pred)

Determines if the range [first, last) is partitioned.

Note

Complexity: at most (N) predicate evaluations where N = distance(first, last).

Return

The is_partitioned algorithm returns bool. The is_partitioned algorithm returns true if each element in the sequence for which pred returns true precedes those for which pred returns false. Otherwise is_partitioned returns false. If the range [first, last) contains less than two elements, the function is always true.

Template Parameters
• FwdIter: The type of the source iterators used for the This iterator type must meet the requirements of a forward iterator.

• Pred: The type of the function/function object to use (deduced).

Parameters
• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

• pred: Refers to the unary predicate which returns true for elements expected to be found in the beginning of the range. The signature of the function should be equivalent to

bool pred(const Type &a);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of types FwdIter can be dereferenced and then implicitly converted to Type.

template<typename ExPolicy, typename FwdIter, typename Pred>
util::detail::algorithm_result<ExPolicy, bool>::type is_partitioned(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred)

Determines if the range [first, last) is partitioned.

The predicate operations in the parallel

is_partitioned algorithm invoked with an execution policy object of type sequenced_policy executes in sequential order in the calling thread.
Note

Complexity: at most (N) predicate evaluations where N = distance(first, last).

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 for the This iterator type must meet the requirements of a forward iterator.

• Pred: The type of the function/function object to use (deduced). Pred must be CopyConstructible when using a parallel policy.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

• pred: Refers to the unary predicate which returns true for elements expected to be found in the beginning of the range. The signature of the function should be equivalent to

bool pred(const Type &a);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of types FwdIter can be dereferenced and then implicitly converted to Type.

The comparison operations in the parallel is_partitioned 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.

Return

The is_partitioned algorithm returns a hpx::future<bool> if the execution policy is of type task_execution_policy and returns bool otherwise. The is_partitioned algorithm returns true if each element in the sequence for which pred returns true precedes those for which pred returns false. Otherwise is_partitioned returns false. If the range [first, last) contains less than two elements, the function is always true.

namespace hpx

Functions

template<typename FwdIter, typename Pred = hpx::parallel::v1::detail::less>
bool is_sorted(FwdIter first, FwdIter last, Pred &&pred = Pred())

Determines if the range [first, last) is sorted. Uses pred to compare elements.

The comparison operations in the parallel

is_sorted algorithm executes in sequential order in the calling thread.
Note

Complexity: at most (N+S-1) comparisons where N = distance(first, last). S = number of partitions

Template Parameters
• FwdIter: The type of the source iterators used for the This iterator type must meet the requirements of a forward iterator.

• Pred: The type of an optional function/function object to use.

Parameters
• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

• pred: Refers to the binary predicate which returns true if the first argument should be treated as less than the second argument. The signature of the function should be equivalent to

bool pred(const Type &a, const Type &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of types FwdIter can be dereferenced and then implicitly converted to Type.

Return

The is_sorted algorithm returns a bool. The is_sorted algorithm returns true if each element in the sequence [first, last) satisfies the predicate passed. If the range [first, last) contains less than two elements, the function always returns true.

template<typename ExPolicy, typename FwdIter, typename Pred = hpx::parallel::v1::detail::less>
hpx::parallel::util::detail::algorithm_result<ExPolicy, bool>::type is_sorted(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred = Pred())

Determines if the range [first, last) is sorted. Uses pred to compare elements.

The comparison operations in the parallel

is_sorted algorithm invoked with an execution policy object of type sequenced_policy executes in sequential order in the calling thread.
Note

Complexity: at most (N+S-1) comparisons where N = distance(first, last). S = number of partitions

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 for the This iterator type must meet the requirements of a forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of is_sorted requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

• pred: Refers to the binary predicate which returns true if the first argument should be treated as less than the second argument. The signature of the function should be equivalent to

bool pred(const Type &a, const Type &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of types FwdIter can be dereferenced and then implicitly converted to Type.

The comparison operations in the parallel is_sorted 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.

Return

The is_sorted algorithm returns a hpx::future<bool> if the execution policy is of type task_execution_policy and returns bool otherwise. The is_sorted algorithm returns a bool if each element in the sequence [first, last) satisfies the predicate passed. If the range [first, last) contains less than two elements, the function always returns true.

template<typename FwdIter, typename Pred = hpx::parallel::v1::detail::less>
FwdIter is_sorted_until(FwdIter first, FwdIter last, Pred &&pred = Pred())

Returns the first element in the range [first, last) that is not sorted. Uses a predicate to compare elements or the less than operator.

The comparison operations in the parallel

is_sorted_until algorithm execute in sequential order in the calling thread.
Note

Complexity: at most (N+S-1) comparisons where N = distance(first, last). S = number of partitions

Template Parameters
• FwdIter: The type of the source iterators used for the This iterator type must meet the requirements of a forward iterator.

• Pred: The type of an optional function/function object to use.

Parameters
• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

• pred: Refers to the binary predicate which returns true if the first argument should be treated as less than the second argument. The signature of the function should be equivalent to

bool pred(const Type &a, const Type &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of types FwdIter can be dereferenced and then implicitly converted to Type.

Return

The is_sorted_until algorithm returns a FwdIter. The is_sorted_until algorithm returns the first unsorted element. If the sequence has less than two elements or the sequence is sorted, last is returned.

template<typename ExPolicy, typename FwdIter, typename Pred = hpx::parallel::v1::detail::less>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type is_sorted_until(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred = Pred())

Returns the first element in the range [first, last) that is not sorted. Uses a predicate to compare elements or the less than operator.

The comparison operations in the parallel

is_sorted_until algorithm invoked with an execution policy object of type sequenced_policy executes in sequential order in the calling thread.
Note

Complexity: at most (N+S-1) comparisons where N = distance(first, last). S = number of partitions

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 for the This iterator type must meet the requirements of a forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of is_sorted_until requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

• pred: Refers to the binary predicate which returns true if the first argument should be treated as less than the second argument. The signature of the function should be equivalent to

bool pred(const Type &a, const Type &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of types FwdIter can be dereferenced and then implicitly converted to Type.

The comparison operations in the parallel is_sorted_until 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.

Return

The is_sorted_until algorithm returns a hpx::future<FwdIter> if the execution policy is of type task_execution_policy and returns FwdIter otherwise. The is_sorted_until algorithm returns the first unsorted element. If the sequence has less than two elements or the sequence is sorted, last is returned.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::less>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::type lexicographical_compare(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&pred = Pred())

Checks if the first range [first1, last1) is lexicographically less than the second range [first2, last2). uses a provided predicate to compare elements.

The comparison operations in the parallel

lexicographical_compare algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most 2 * min(N1, N2) applications of the comparison operation, where N1 = std::distance(first1, last) and N2 = std::distance(first2, last2).

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of lexicographical_compare requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• pred: Refers to the comparison function that the first and second ranges will be applied to

The comparison operations in the parallel lexicographical_compare 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

Lexicographical comparison is an operation with the following properties

• Two ranges are compared element by element

• The first mismatching element defines which range is lexicographically less or greater than the other

• If one range is a prefix of another, the shorter range is lexicographically less than the other

• If two ranges have equivalent elements and are of the same length, then the ranges are lexicographically equal

• An empty range is lexicographically less than any non-empty range

• Two empty ranges are lexicographically equal

Return

The lexicographically_compare algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The lexicographically_compare algorithm returns true if the first range is lexicographically less, otherwise it returns false. range [first2, last2), it returns false.

namespace hpx

Functions

template<typename ExPolicy, typename RndIter, typename Comp>
util::detail::algorithm_result<ExPolicy>::type make_heap(ExPolicy &&policy, RndIter first, RndIter last, Comp &&comp)

Constructs a max heap in the range [first, last).

The predicate operations in the parallel

make_heap algorithm invoked with an execution policy object of type sequential_execution_policy executes in sequential order in the calling thread.
Note

Complexity: at most (3*N) comparisons where N = distance(first, last).

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.

• RndIter: The type of the source iterators used for algorithm. This iterator must meet the requirements for a random access iterator.

Parameters
• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

• comp: Refers to the binary predicate which returns true if the first argument should be treated as less than the second. The signature of the function should be equivalent to

bool comp(const Type &a, const Type &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type must be such that objects of types RndIter can be dereferenced and then implicitly converted to Type.

The comparison operations in the parallel make_heap 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.

Return

The make_heap algorithm returns a hpx::future<void> if the execution policy is of type task_execution_policy and returns void otherwise.

template<typename ExPolicy, typename RndIter>
hpx::parallel::util::detail::algorithm_result<ExPolicy>::type make_heap(ExPolicy &&policy, RndIter first, RndIter last)

Constructs a max heap in the range [first, last). Uses the operator < for comparisons.

The predicate operations in the parallel

make_heap algorithm invoked with an execution policy object of type sequential_execution_policy executes in sequential order in the calling thread.
Note

Complexity: at most (3*N) comparisons where N = distance(first, last).

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.

• RndIter: The type of the source iterators used for algorithm. This iterator must meet the requirements for a random access iterator.

Parameters
• first: Refers to the beginning of the sequence of elements of that the algorithm will be applied to.

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

The comparison operations in the parallel make_heap 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.

Return

The make_heap algorithm returns a hpx::future<void> if the execution policy is of type task_execution_policy and returns void otherwise.

namespace hpx

Functions

template<typename ExPolicy, typename RandIter1, typename RandIter2, typename RandIter3, typename Comp = detail::less>
util::detail::algorithm_result<ExPolicy, RandIter3>::type merge(ExPolicy &&policy, RandIter1 first1, RandIter1 last1, RandIter2 first2, RandIter2 last2, RandIter3 dest, Comp &&comp = Comp())

Merges two sorted ranges [first1, last1) and [first2, last2) into one sorted range beginning at dest. The order of equivalent elements in the each of original two ranges is preserved. For equivalent elements in the original two ranges, the elements from the first range precede the elements from the second range. The destination range cannot overlap with either of the input ranges.

The assignments in the parallel

merge algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs O(std::distance(first1, last1) + std::distance(first2, last2)) applications of the comparison comp and the each projection.

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.

• RandIter1: The type of the source iterators used (deduced) representing the first sorted range. This iterator type must meet the requirements of an random access iterator.

• RandIter2: The type of the source iterators used (deduced) representing the second sorted range. This iterator type must meet the requirements of an random access iterator.

• RandIter3: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an random access iterator.

• Comp: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of merge requires Comp to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the first range of elements the algorithm will be applied to.

• last1: Refers to the end of the first range of elements the algorithm will be applied to.

• first2: Refers to the beginning of the second range of elements the algorithm will be applied to.

• last2: Refers to the end of the second range of elements the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

• comp: comp is a callable object which returns true if the first argument is less than the second, and false otherwise. The signature of this comparison should be equivalent to:

bool comp(const Type1 &a, const Type2 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types RandIter1 and RandIter2 can be dereferenced and then implicitly converted to both Type1 and Type2

The assignments in the parallel merge 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.

Return

The merge algorithm returns a hpx::future<RandIter3> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_tuple<RandIter3> otherwise. The merge algorithm returns the destination iterator to the end of the dest range.

template<typename ExPolicy, typename RandIter, typename Comp = detail::less>
util::detail::algorithm_result<ExPolicy>::type inplace_merge(ExPolicy &&policy, RandIter first, RandIter middle, RandIter last, Comp &&comp = Comp())

Merges two consecutive sorted ranges [first, middle) and [middle, last) into one sorted range [first, last). The order of equivalent elements in the each of original two ranges is preserved. For equivalent elements in the original two ranges, the elements from the first range precede the elements from the second range.

The assignments in the parallel

inplace_merge algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs O(std::distance(first, last)) applications of the comparison comp and the each projection.

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.

• RandIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an random access iterator.

• Comp: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of inplace_merge requires Comp to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the first sorted range the algorithm will be applied to.

• middle: Refers to the end of the first sorted range and the beginning of the second sorted range the algorithm will be applied to.

• last: Refers to the end of the second sorted range the algorithm will be applied to.

• comp: comp is a callable object which returns true if the first argument is less than the second, and false otherwise. The signature of this comparison should be equivalent to:

bool comp(const Type1 &a, const Type2 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types RandIter can be dereferenced and then implicitly converted to both Type1 and Type2

The assignments in the parallel inplace_merge 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.

Return

The inplace_merge algorithm returns a hpx::future<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise. The inplace_merge algorithm returns the source iterator last

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter, typename Proj = util::projection_identity, typename F = detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter>::type min_element(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f = F(), Proj &&proj = Proj())

Finds the smallest element in the range [first, last) using the given comparison function f.

The comparisons in the parallel

min_element algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly max(N-1, 0) comparisons, where N = std::distance(first, last).

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 min_element requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: The binary predicate which returns true if the the left argument is less than the right element. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The comparisons in the parallel min_element 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.

Return

The min_element algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The min_element algorithm returns the iterator to the smallest element in the range [first, last). If several elements in the range are equivalent to the smallest element, returns the iterator to the first such element. Returns last if the range is empty.

template<typename ExPolicy, typename FwdIter, typename Proj = util::projection_identity, typename F = detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter>::type max_element(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f = F(), Proj &&proj = Proj())

Finds the greatest element in the range [first, last) using the given comparison function f.

The comparisons in the parallel

max_element algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly max(N-1, 0) comparisons, where N = std::distance(first, last).

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 max_element requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: The binary predicate which returns true if the This argument is optional and defaults to std::less. the left argument is less than the right element. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The comparisons in the parallel max_element 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.

Return

The max_element algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The max_element algorithm returns the iterator to the smallest element in the range [first, last). If several elements in the range are equivalent to the smallest element, returns the iterator to the first such element. Returns last if the range is empty.

template<typename ExPolicy, typename FwdIter, typename Proj = util::projection_identity, typename F = detail::less>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::min(FwdIter), tag::max(FwdIter)>>::type minmax_element(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f = F(), Proj &&proj = Proj())

Finds the greatest element in the range [first, last) using the given comparison function f.

The comparisons in the parallel

minmax_element algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most max(floor(3/2*(N-1)), 0) applications of the predicate, where N = std::distance(first, last).

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 minmax_element requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: The binary predicate which returns true if the the left argument is less than the right element. This argument is optional and defaults to std::less. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The comparisons in the parallel minmax_element 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.

Return

The minmax_element algorithm returns a hpx::future<tagged_pair<tag::min(FwdIter), tag::max(FwdIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::min(FwdIter), tag::max(FwdIter)> otherwise. The minmax_element algorithm returns a pair consisting of an iterator to the smallest element as the first element and an iterator to the greatest element as the second. Returns std::make_pair(first, first) if the range is empty. If several elements are equivalent to the smallest element, the iterator to the first such element is returned. If several elements are equivalent to the largest element, the iterator to the last such element is returned.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, std::pair<FwdIter1, FwdIter2>>::type mismatch(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred())

Returns true if the range [first1, last1) is mismatch to the range [first2, last2), and false otherwise.

The comparison operations in the parallel

mismatch algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most min(last1 - first1, last2 - first2) applications of the predicate f. If FwdIter1 and FwdIter2 meet the requirements of RandomAccessIterator and (last1 - first1) != (last2 - first2) then no applications of the predicate f are made.

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of mismatch requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• op: The binary predicate which returns true if the elements should be treated as mismatch. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

The comparison operations in the parallel mismatch 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

The two ranges are considered mismatch if, for every iterator i in the range [first1,last1), *i mismatchs *(first2 + (i - first1)). This overload of mismatch uses operator== to determine if two elements are mismatch.

Return

The mismatch algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The mismatch algorithm returns true if the elements in the two ranges are mismatch, otherwise it returns false. If the length of the range [first1, last1) does not mismatch the length of the range [first2, last2), it returns false.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, std::pair<FwdIter1, FwdIter2>>::type mismatch(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, Pred &&op = Pred())

Returns std::pair with iterators to the first two non-equivalent elements.

The comparison operations in the parallel

mismatch algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most last1 - first1 applications of the predicate f.

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.

• FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of mismatch requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• op: The binary predicate which returns true if the elements should be treated as mismatch. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

The comparison operations in the parallel mismatch 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.

Return

The mismatch algorithm returns a hpx::future<std::pair<FwdIter1, FwdIter2> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns std::pair<FwdIter1, FwdIter2> otherwise. The mismatch algorithm returns the first mismatching pair of elements from two ranges: one defined by [first1, last1) and another defined by [first2, last2).

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, FwdIter2>::type move(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)

Moves the elements in the range [first, last), to another range beginning at dest. After this operation the elements in the moved-from range will still contain valid values of the appropriate type, but not necessarily the same values as before the move.

The move assignments in the parallel

move algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first move 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 move assignments.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

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.

• dest: Refers to the beginning of the destination range.

The move assignments in the parallel move 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.

Return

The move algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The move algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element moved.

namespace hpx

Functions

template<typename RandIter>
util::detail::algorithm_result<ExPolicy>::type partial_sort(ExPolicy &&policy, RandIter first, RandIter middle, RandIter last)

Places the first middle - first elements from the range [first, last) as sorted with respect to comp into the range [first, middle). The rest of the elements in the range [middle, last) are placed in an unspecified order.

Note

Complexity: Approximately (last - first) * log(middle - first) comparisons.

Return

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

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 applies user-provided function objects.

• RandIter: The type of the source begin, middle, and end iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

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.

• middle: Refers to the middle 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.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename BidirIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, BidirIter>::type stable_partition(ExPolicy &&policy, BidirIter first, BidirIter last, F &&f, Proj &&proj = Proj())

Permutes the elements in the range [first, last) such that there exists an iterator i such that for every iterator j in the range [first, i) INVOKE(f, INVOKE (proj, *j)) != false, and for every iterator k in the range [i, last), INVOKE(f, INVOKE (proj, *k)) == false

The invocations of

f in the parallel stable_partition algorithm invoked with an execution policy object of type sequenced_policy executes in sequential order in the calling thread.
Note

Complexity: At most (last - first) * log(last - first) swaps, but only linear number of swaps if there is enough extra memory. Exactly last - first applications of the predicate and projection.

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 invocations of f.

• BidirIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.

• F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of transform requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Unary predicate which returns true if the element should be ordered before other elements. Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

bool fun(const Type &a);


The signature does not need to have const&. The type

Type must be such that an object of type BidirIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate f is invoked.

The invocations of f in the parallel stable_partition 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.

Return

The stable_partition algorithm returns an iterator i such that for every iterator j in the range [first, i), f(*j) != false INVOKE(f, INVOKE(proj, *j)) != false, and for every iterator k in the range [i, last), f(*k) == false INVOKE(f, INVOKE (proj, *k)) == false. The relative order of the elements in both groups is preserved. If the execution policy is of type parallel_task_policy the algorithm returns a future<> referring to this iterator.

template<typename ExPolicy, typename FwdIter, typename Pred, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type partition(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred, Proj &&proj = Proj())

Reorders the elements in the range [first, last) in such a way that all elements for which the predicate pred returns true precede the elements for which the predicate pred returns false. Relative order of the elements is not preserved.

The assignments in the parallel

partition algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most 2 * (last - first) swaps. Exactly last - first applications of the predicate and projection.

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.

• Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of partition requires Pred to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• pred: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an unary predicate for partitioning the source iterators. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type InIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel partition 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.

Return

The partition algorithm returns a hpx::future<FwdIter> if the execution policy is of type parallel_task_policy and returns FwdIter otherwise. The partition algorithm returns the iterator to the first element of the second group.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in(FwdIter1), tag::out1(FwdIter2), tag::out2(FwdIter3)>>::type partition_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest_true, FwdIter3 dest_false, Pred &&pred, Proj &&proj = Proj())

Copies the elements in the range, defined by [first, last), to two different ranges depending on the value returned by the predicate pred. The elements, that satisfy the predicate pred, are copied to the range beginning at dest_true. The rest of the elements are copied to the range beginning at dest_false. The order of the elements is preserved.

The assignments in the parallel

partition_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.

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.

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

• FwdIter2: The type of the iterator representing the destination range for the elements that satisfy the predicate pred (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter3: The type of the iterator representing the destination range for the elements that don’t satisfy the predicate pred (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of partition_copy requires Pred to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• dest_true: Refers to the beginning of the destination range for the elements that satisfy the predicate pred.

• dest_false: Refers to the beginning of the destination range for the elements that don’t satisfy the predicate pred.

• pred: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an unary predicate for partitioning the source iterators. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel partition_copy 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.

Return

The partition_copy algorithm returns a hpx::future<tagged_tuple<tag::in(InIter), tag::out1(OutIter1), tag::out2(OutIter2)> > if the execution policy is of type parallel_task_policy and returns tagged_tuple<tag::in(InIter), tag::out1(OutIter1), tag::out2(OutIter2)> otherwise. The partition_copy algorithm returns the tuple of the source iterator last, the destination iterator to the end of the dest_true range, and the destination iterator to the end of the dest_false range.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter, typename T, typename F>
util::detail::algorithm_result<ExPolicy, T>::type reduce(ExPolicy &&policy, FwdIter first, FwdIter last, T init, F &&f)

Returns GENERALIZED_SUM(f, init, *first, …, *(first + (last - first) - 1)).

The reduce operations in the parallel

reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate f.

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 begin and end 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 copy_if requires F to meet the requirements of CopyConstructible.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&. The types

Type1 Ret must be such that an object of type FwdIter can be dereferenced and then implicitly converted to any of those types.

• init: The initial value for the generalized sum.

The reduce operations in the parallel copy_if 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.

The difference between

reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.
Return

The reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise. The reduce algorithm returns the result of the generalized sum over the elements given by the input range [first, last).

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

• a1 when N is 1

• op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

• b1, …, bN may be any permutation of a1, …, aN and

• 1 < K+1 = M <= N.

template<typename ExPolicy, typename FwdIter, typename T>
util::detail::algorithm_result<ExPolicy, T>::type reduce(ExPolicy &&policy, FwdIter first, FwdIter last, T init)

Returns GENERALIZED_SUM(+, init, *first, …, *(first + (last - first) - 1)).

The reduce operations in the parallel

reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the operator+().

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 begin and end iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

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.

• init: The initial value for the generalized sum.

The reduce operations in the parallel copy_if 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.

The difference between

reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.
Return

The reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise. The reduce algorithm returns the result of the generalized sum (applying operator+()) over the elements given by the input range [first, last).

Note

GENERALIZED_SUM(+, a1, …, aN) is defined as follows:

• a1 when N is 1

• op(GENERALIZED_SUM(+, b1, …, bK), GENERALIZED_SUM(+, bM, …, bN)), where:

• b1, …, bN may be any permutation of a1, …, aN and

• 1 < K+1 = M <= N.

template<typename ExPolicy, typename FwdIter>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<FwdIter>::value_type>::type reduce(ExPolicy &&policy, FwdIter first, FwdIter last)

Returns GENERALIZED_SUM(+, T(), *first, …, *(first + (last - first) - 1)).

The reduce operations in the parallel

reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the operator+().

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 begin and end iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

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.

The reduce operations in the parallel copy_if 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.

The difference between

reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.
Return

The reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise (where T is the value_type of FwdIter). The reduce algorithm returns the result of the generalized sum (applying operator+()) over the elements given by the input range [first, last).

Note

The type of the initial value (and the result type) T is determined from the value_type of the used FwdIter.

Note

GENERALIZED_SUM(+, a1, …, aN) is defined as follows:

• a1 when N is 1

• op(GENERALIZED_SUM(+, b1, …, bK), GENERALIZED_SUM(+, bM, …, bN)), where:

• b1, …, bN may be any permutation of a1, …, aN and

• 1 < K+1 = M <= N.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename RanIter, typename RanIter2, typename FwdIter1, typename FwdIter2, typename Compare = std::equal_to<typename std::iterator_traits<RanIter>::value_type>, typename Func = std::plus<typename std::iterator_traits<RanIter2>::value_type>>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::type reduce_by_key(ExPolicy &&policy, RanIter key_first, RanIter key_last, RanIter2 values_first, FwdIter1 keys_output, FwdIter2 values_output, Compare &&comp = Compare(), Func &&func = Func())

Reduce by Key performs an inclusive scan reduction operation on elements supplied in key/value pairs. The algorithm produces a single output value for each set of equal consecutive keys in [key_first, key_last). the value being the GENERALIZED_NONCOMMUTATIVE_SUM(op, init, *first, …, *(first + (i - result))). for the run of consecutive matching keys. The number of keys supplied must match the number of values.

comp has to induce a strict weak ordering on the values.

Note

Complexity: O(last - first) applications of the predicate op.

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 applies user-provided function objects.

• RanIter: The type of the key iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• RanIter2: The type of the value iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• FwdIter1: The type of the iterator representing the destination key range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the iterator representing the destination value range (deduced). This iterator type must meet the requirements of an forward iterator.

• Compare: The type of the optional function/function object to use to compare keys (deduced). Assumed to be std::equal_to otherwise.

• Func: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• key_first: Refers to the beginning of the sequence of key elements the algorithm will be applied to.

• key_last: Refers to the end of the sequence of key elements the algorithm will be applied to.

• values_first: Refers to the beginning of the sequence of value elements the algorithm will be applied to.

• keys_output: Refers to the start output location for the keys produced by the algorithm.

• values_output: Refers to the start output location for the values produced by the algorithm.

• comp: comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator.

• func: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&. The types

Type1 Ret must be such that an object of type FwdIter can be dereferenced and then implicitly converted to any of those types.

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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.

Return

The reduce_by_key algorithm returns a hpx::future<pair<Iter1,Iter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns pair<Iter1,Iter2> otherwise.

namespace hpx

Functions

template<typename FwdIter, typename T>
FwdIter remove(FwdIter first, FwdIter last, T const &value)

Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range. This version removes all elements that are equal to value.

The assignments in the parallel

remove algorithm execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the operator==().

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.

• T: The type of the value to remove (deduced). This value type must 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.

• value: Specifies the value of elements to remove.

Return

The remove algorithm returns a FwdIter. The remove algorithm returns the iterator to the new end of the range.

template<typename ExPolicy, typename FwdIter, typename T>
util::detail::algorithm_result<ExPolicy, FwdIter>::type remove(ExPolicy &&policy, FwdIter first, FwdIter last, T const &value)

Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range. This version removes all elements that are equal to value.

The assignments in the parallel

remove algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the operator==().

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

• T: The type of the value to remove (deduced). This value type must 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.

• value: Specifies the value of elements to remove.

The assignments in the parallel remove 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.

Return

The remove algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The remove algorithm returns the iterator to the new end of the range.

template<typename FwdIter, typename Pred>
FwdIter remove_if(FwdIter first, FwdIter last, Pred &&pred)

Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range. This version removes all elements for which predicate pred returns true.

The assignments in the parallel

remove_if algorithm execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate pred.

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

• Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of remove_if requires Pred 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.

• pred: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

Return

The remove_if algorithm returns a FwdIter. The remove_if algorithm returns the iterator to the new end of the range.

template<typename ExPolicy, typename FwdIter, typename Pred>
util::detail::algorithm_result<ExPolicy, FwdIter>::type remove_if(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred)

Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range. This version removes all elements for which predicate pred returns true.

The assignments in the parallel

remove_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate pred.

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.

• Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of remove_if requires Pred 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.

• pred: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

The assignments in the parallel remove_if 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.

Return

The remove_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. The remove_if algorithm returns the iterator to the new end of the range.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::type remove_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T const &val, Proj &&proj = Proj())

Copies the elements in the range, defined by [first, last), to another range beginning at dest. Copies only the elements for which the comparison operator returns false when compare to val. The order of the elements that are not removed is preserved.

Effects: Copies all the elements referred to by the iterator it in the range [first,last) for which the following corresponding conditions do not hold: INVOKE(proj, *it) == value

The assignments in the parallel

remove_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type that the result of dereferencing FwdIter1 is compared to.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• dest: Refers to the beginning of the destination range.

• val: Value to be removed.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel remove_copy 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.

Return

The remove_copy algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::type remove_copy_if(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F &&f, Proj &&proj = Proj())

Copies the elements in the range, defined by [first, last), to another range beginning at dest. Copies only the elements for which the predicate f returns false. The order of the elements that are not removed is preserved.

Effects: Copies all the elements referred to by the iterator it in the range [first,last) for which the following corresponding conditions do not hold: INVOKE(pred, INVOKE(proj, *it)) != false.

The assignments in the parallel

remove_copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.

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.

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

• FwdIter2: The type of the iterator representing the destination range (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 copy_if requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• dest: Refers to the beginning of the destination range.

• f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the elements to be removed. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel remove_copy_if 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.

Return

The remove_copy_if algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter, typename T1, typename T2, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type replace(ExPolicy &&policy, FwdIter first, FwdIter last, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria with new_value in the range [first, last).

Effects: Substitutes elements referred by the iterator it in the range [first, last) with new_value, when the following corresponding conditions hold: INVOKE(proj, *it) == old_value

The assignments in the parallel

replace algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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.

• T1: The type of the old value to replace (deduced).

• T2: The type of the new values to replace (deduced).

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• old_value: Refers to the old value of the elements to replace.

• new_value: Refers to the new value to use as the replacement.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel replace 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.

Return

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

template<typename ExPolicy, typename FwdIter, typename F, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type replace_if(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f, T const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria (for which predicate f returns true) with new_value in the range [first, last).

Effects: Substitutes elements referred by the iterator it in the range [first, last) with new_value, when the following corresponding conditions hold: INVOKE(f, INVOKE(proj, *it)) != false

The assignments in the parallel

replace_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first applications of the predicate.

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. (deduced).

• T: The type of the new values to replace (deduced).

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the elements which need to replaced. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

• new_value: Refers to the new value to use as the replacement.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel replace_if 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.

Return

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 FwdIter1, typename FwdIter2, typename T1, typename T2, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type replace_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, last) to another range beginning at dest replacing all elements satisfying a specific criteria with new_value.

Effects: Assigns to every iterator it in the range [result, result + (last - first)) either new_value or *(first + (it - result)) depending on whether the following corresponding condition holds: INVOKE(proj, *(first + (i - result))) == old_value

The assignments in the parallel

replace_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first applications of the predicate.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• T1: The type of the old value to replace (deduced).

• T2: The type of the new values to replace (deduced).

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• dest: Refers to the beginning of the destination range.

• old_value: Refers to the old value of the elements to replace.

• new_value: Refers to the new value to use as the replacement.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel replace_copy 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.

Return

The replace_copy algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The copy algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type replace_copy_if(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F &&f, T const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, last) to another range beginning at dest replacing all elements satisfying a specific criteria with new_value.

Effects: Assigns to every iterator it in the range [result, result + (last - first)) either new_value or *(first + (it - result)) depending on whether the following corresponding condition holds: INVOKE(f, INVOKE(proj, *(first + (i - result)))) != false

The assignments in the parallel

replace_copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first applications of the predicate.

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.

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

• FwdIter2: The type of the iterator representing the destination range (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. (deduced).

• T: The type of the new values to replace (deduced).

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• dest: Refers to the beginning of the destination range.

• f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the elements which need to replaced. The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

• new_value: Refers to the new value to use as the replacement.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel replace_copy_if 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.

Return

The replace_copy_if algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The replace_copy_if algorithm returns the input iterator last and the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename BidirIter>
util::detail::algorithm_result<ExPolicy, BidirIter>::type reverse(ExPolicy &&policy, BidirIter first, BidirIter last)

Reverses the order of the elements in the range [first, last). Behaves as if applying std::iter_swap to every pair of iterators first+i, (last-i) - 1 for each non-negative i < (last-first)/2.

The assignments in the parallel

reverse algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last.

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.

• BidirIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an bidirectional iterator.

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.

The assignments in the parallel reverse 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.

Return

The reverse algorithm returns a hpx::future<BidirIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns BidirIter otherwise. It returns last.

template<typename ExPolicy, typename BidirIter, typename FwdIter>
util::detail::algorithm_result<ExPolicy, util::in_out_result<BidirIter, FwdIter>>::type reverse_copy(ExPolicy &&policy, BidirIter first, BidirIter last, FwdIter dest_first)

Copies the elements from the range [first, last) to another range beginning at dest_first in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(dest_first + (last - first) - 1 - i) = *(first + i) once for each non-negative i < (last - first) If the source and destination ranges (that is, [first, last) and [dest_first, dest_first+(last-first)) respectively) overlap, the behavior is undefined.

The assignments in the parallel

reverse_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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.

• BidirIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an bidirectional iterator.

• FwdIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

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.

• dest_first: Refers to the begin of the destination range.

The assignments in the parallel reverse_copy 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.

Return

The reverse_copy algorithm returns a hpx::future<tagged_pair<tag::in(BidirIter), tag::out(FwdIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(BidirIter), tag::out(FwdIter)> otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter, FwdIter>>::type rotate(ExPolicy &&policy, FwdIter first, FwdIter new_first, FwdIter last)

Performs a left rotation on a range of elements. Specifically, rotate swaps the elements in the range [first, last) in such a way that the element new_first becomes the first element of the new range and new_first - 1 becomes the last element.

The assignments in the parallel

rotate algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last.

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.

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.

• new_first: Refers to the element that should appear at the beginning of the rotated range.

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

The assignments in the parallel rotate 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

The type of dereferenced FwdIter must meet the requirements of MoveAssignable and MoveConstructible.

Return

The rotate algorithm returns a hpx::future<tagged_pair<tag::begin(FwdIter), tag::end(FwdIter)> > if the execution policy is of type parallel_task_policy and returns tagged_pair<tag::begin(FwdIter), tag::end(FwdIter)> otherwise. The rotate algorithm returns the iterator equal to pair(first + (last - new_first), last).

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::type rotate_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 new_first, FwdIter1 last, FwdIter2 dest_first)

Copies the elements from the range [first, last), to another range beginning at dest_first in such a way, that the element new_first becomes the first element of the new range and new_first - 1 becomes the last element.

The assignments in the parallel

rotate_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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.

• FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an bidirectional iterator.

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

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.

• new_first: Refers to the element that should appear at the beginning of the rotated range.

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

• dest_first: Refers to the begin of the destination range.

The assignments in the parallel rotate_copy 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.

Return

The rotate_copy algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The rotate_copy algorithm returns the output iterator to the element past the last element copied.

namespace hpx

Functions

template<typename FwdIter, typename FwdIter2, typename Pred = detail::equal_to>
FwdIter search(FwdIter first, FwdIter last, FwdIter2 s_first, FwdIter2 s_last, Pred &&op = Pred())

Searches the range [first, last) for any elements in the range [s_first, s_last). Uses a provided predicate to compare elements.

The comparison operations in the parallel

search algorithm execute in sequential order in the calling thread.
Note

Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = distance(first, last).

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

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• first: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• s_first: Refers to the beginning of the sequence of elements the algorithm will be searching for.

• s_last: Refers to the end of the sequence of elements of the algorithm will be searching for.

• op: Refers to the binary predicate which returns true if the elements should be treated as equal. the signature of the function should be equivalent to

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

Return

The search algorithm returns a hpx::future<FwdIter> if the execution policy is of type task_execution_policy and returns FwdIter otherwise. The search algorithm returns an iterator to the beginning of the first subsequence [s_first, s_last) in range [first, last). If the length of the subsequence [s_first, s_last) is greater than the length of the range [first, last), last is returned. Additionally if the size of the subsequence is empty first is returned. If no subsequence is found, last is returned.

template<typename ExPolicy, typename FwdIter, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter>::type search(ExPolicy &&policy, FwdIter first, FwdIter last, FwdIter2 s_first, FwdIter2 s_last, Pred &&op = Pred())

Searches the range [first, last) for any elements in the range [s_first, s_last). Uses a provided predicate to compare elements.

The comparison operations in the parallel

search algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = distance(first, last).

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 for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• s_first: Refers to the beginning of the sequence of elements the algorithm will be searching for.

• s_last: Refers to the end of the sequence of elements of the algorithm will be searching for.

• op: Refers to the binary predicate which returns true if the elements should be treated as equal. the signature of the function should be equivalent to

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

The comparison operations in the parallel search 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.

Return

The search algorithm returns a hpx::future<FwdIter> if the execution policy is of type task_execution_policy and returns FwdIter otherwise. The search algorithm returns an iterator to the beginning of the first subsequence [s_first, s_last) in range [first, last). If the length of the subsequence [s_first, s_last) is greater than the length of the range [first, last), last is returned. Additionally if the size of the subsequence is empty first is returned. If no subsequence is found, last is returned.

template<typename FwdIter, typename FwdIter2, typename Pred = detail::equal_to>
FwdIter search_n(FwdIter first, std::size_t count, FwdIter2 s_first, FwdIter2 s_last, Pred &&op = Pred())

Searches the range [first, last) for any elements in the range [s_first, s_last). Uses a provided predicate to compare elements.

The comparison operations in the parallel

search_n algorithm execute in sequential order in the calling thread.
Note

Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = count.

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

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• first: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• count: Refers to the range of elements of the first range the algorithm will be applied to.

• s_first: Refers to the beginning of the sequence of elements the algorithm will be searching for.

• s_last: Refers to the end of the sequence of elements of the algorithm will be searching for.

• op: Refers to the binary predicate which returns true if the elements should be treated as equal. the signature of the function should be equivalent to

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

Return

The search_n algorithm returns FwdIter. The search_n algorithm returns an iterator to the beginning of the last subsequence [s_first, s_last) in range [first, first+count). If the length of the subsequence [s_first, s_last) is greater than the length of the range [first, first+count), first is returned. Additionally if the size of the subsequence is empty or no subsequence is found, first is also returned.

template<typename ExPolicy, typename FwdIter, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter>::type search_n(ExPolicy &&policy, FwdIter first, std::size_t count, FwdIter2 s_first, FwdIter2 s_last, Pred &&op = Pred())

Searches the range [first, last) for any elements in the range [s_first, s_last). Uses a provided predicate to compare elements.

The comparison operations in the parallel

search_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = count.

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 for the first range (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• count: Refers to the range of elements of the first range the algorithm will be applied to.

• s_first: Refers to the beginning of the sequence of elements the algorithm will be searching for.

• s_last: Refers to the end of the sequence of elements of the algorithm will be searching for.

• op: Refers to the binary predicate which returns true if the elements should be treated as equal. the signature of the function should be equivalent to

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

The comparison operations in the parallel search_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.

Return

The search_n algorithm returns a hpx::future<FwdIter> if the execution policy is of type task_execution_policy and returns FwdIter otherwise. The search_n algorithm returns an iterator to the beginning of the last subsequence [s_first, s_last) in range [first, first+count). If the length of the subsequence [s_first, s_last) is greater than the length of the range [first, first+count), first is returned. Additionally if the size of the subsequence is empty or no subsequence is found, first is also returned.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter3>::type::type set_difference(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, FwdIter3 dest, Pred &&op = Pred())

Constructs a sorted range beginning at dest consisting of all elements present in the range [first1, last1) and not present in the range [first2, last2). This algorithm expects both input ranges to be sorted with the given binary predicate f.

Equivalent elements are treated individually, that is, if some element is found

m times in [first1, last1) and n times in [first2, last2), it will be copied to dest exactly std::max(m-n, 0) times. The resulting range cannot overlap with either of the input ranges.
Note

Complexity: At most 2*(N1 + N2 - 1) comparisons, where N1 is the length of the first sequence and N2 is the length of the second sequence.

The resulting range cannot overlap with either of the input ranges.

The application of function objects in parallel algorithm invoked with a sequential execution policy object execute in sequential order in the calling thread (

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 applies user-provided function objects.

• FwdIter1: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter3: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of set_difference requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type1 must be such that objects of type InIter can be dereferenced and then implicitly converted to Type1

The application of function objects in parallel 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.

Return

The set_difference algorithm returns a hpx::future<FwdIter3> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter3 otherwise. The set_difference algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter3>::type set_intersection(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, FwdIter3 dest, Pred &&op = Pred())

Constructs a sorted range beginning at dest consisting of all elements present in both sorted ranges [first1, last1) and [first2, last2). This algorithm expects both input ranges to be sorted with the given binary predicate f.

If some element is found

m times in [first1, last1) and n times in [first2, last2), the first std::min(m, n) elements will be copied from the first range to the destination range. The order of equivalent elements is preserved. The resulting range cannot overlap with either of the input ranges.
Note

Complexity: At most 2*(N1 + N2 - 1) comparisons, where N1 is the length of the first sequence and N2 is the length of the second sequence.

The resulting range cannot overlap with either of the input ranges.

The application of function objects in parallel algorithm invoked with a sequential execution policy object execute in sequential order in the calling thread (

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 applies user-provided function objects.

• FwdIter1: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter3: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of set_intersection requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type1 must be such that objects of type InIter can be dereferenced and then implicitly converted to Type1

The application of function objects in parallel 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.

Return

The set_intersection algorithm returns a hpx::future<FwdIter3> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter3 otherwise. The set_intersection algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter3>::type::type set_symmetric_difference(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, FwdIter3 dest, Pred &&op = Pred())

Constructs a sorted range beginning at dest consisting of all elements present in either of the sorted ranges [first1, last1) and [first2, last2), but not in both of them are copied to the range beginning at dest. The resulting range is also sorted. This algorithm expects both input ranges to be sorted with the given binary predicate f.

If some element is found

m times in [first1, last1) and n times in [first2, last2), it will be copied to dest exactly std::abs(m-n) times. If m>n, then the last m-n of those elements are copied from [first1,last1), otherwise the last n-m elements are copied from [first2,last2). The resulting range cannot overlap with either of the input ranges.
Note

Complexity: At most 2*(N1 + N2 - 1) comparisons, where N1 is the length of the first sequence and N2 is the length of the second sequence.

The resulting range cannot overlap with either of the input ranges.

The application of function objects in parallel algorithm invoked with a sequential execution policy object execute in sequential order in the calling thread (

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 applies user-provided function objects.

• FwdIter1: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter3: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of set_symmetric_difference requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type1 must be such that objects of type InIter can be dereferenced and then implicitly converted to Type1

The application of function objects in parallel 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.

Return

The set_symmetric_difference algorithm returns a hpx::future<FwdIter3> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter3 otherwise. The set_symmetric_difference algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter3>::type::type set_union(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, FwdIter3 dest, Pred &&op = Pred())

Constructs a sorted range beginning at dest consisting of all elements present in one or both sorted ranges [first1, last1) and [first2, last2). This algorithm expects both input ranges to be sorted with the given binary predicate f.

If some element is found

m times in [first1, last1) and n times in [first2, last2), then all m elements will be copied from [first1, last1) to dest, preserving order, and then exactly std::max(n-m, 0) elements will be copied from [first2, last2) to dest, also preserving order.
Note

Complexity: At most 2*(N1 + N2 - 1) comparisons, where N1 is the length of the first sequence and N2 is the length of the second sequence.

The resulting range cannot overlap with either of the input ranges.

The application of function objects in parallel algorithm invoked with a sequential execution policy object execute in sequential order in the calling thread (

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 applies user-provided function objects.

• FwdIter1: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an forward iterator.

• FwdIter3: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.

• Op: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of set_union requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.

• last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.

• first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

• last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

• op: The binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The type

Type1 must be such that objects of type InIter can be dereferenced and then implicitly converted to Type1

The application of function objects in parallel 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.

Return

The set_union algorithm returns a hpx::future<FwdIter3> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter3 otherwise. The set_union algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename RandomIt, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, RandomIt>::type sort(ExPolicy &&policy, RandomIt first, RandomIt last, Comp &&comp = Comp(), Proj &&proj = Proj())

Sorts the elements in the range [first, last) in ascending order. The order of equal elements is not guaranteed to be preserved. The function uses the given comparison function object comp (defaults to using operator<()).

A sequence is sorted with respect to a comparator

comp and a projection proj if for every iterator i pointing to the sequence and every non-negative integer n such that i + n is a valid iterator pointing to an element of the sequence, and INVOKE(comp, INVOKE(proj, *(i + n)), INVOKE(proj, *i)) == false.
Note

Complexity: O(Nlog(N)), where N = std::distance(first, last) comparisons.

comp has to induce a strict weak ordering on the values.

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 applies user-provided function objects.

• Iter: The type of the source iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• Comp: The type of the function/function object to use (deduced).

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• comp: comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator.

• proj: Specifies the function (or function object) which will be invoked for each pair of elements as a projection operation before the actual predicate comp is invoked.

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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.

Return

The sort algorithm returns a hpx::future<RandomIt> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns RandomIt otherwise. The algorithm returns an iterator pointing to the first element after the last element in the input sequence.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename KeyIter, typename ValueIter, typename Compare = detail::less>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in1(KeyIter), tag::in2(ValueIter)>>::type sort_by_key(ExPolicy &&policy, KeyIter key_first, KeyIter key_last, ValueIter value_first, Compare &&comp = Compare())

Sorts one range of data using keys supplied in another range. The key elements in the range [key_first, key_last) are sorted in ascending order with the corresponding elements in the value range moved to follow the sorted order. The algorithm is not stable, the order of equal elements is not guaranteed to be preserved. The function uses the given comparison function object comp (defaults to using operator<()).

A sequence is sorted with respect to a comparator

comp and a projection proj if for every iterator i pointing to the sequence and every non-negative integer n such that i + n is a valid iterator pointing to an element of the sequence, and INVOKE(comp, INVOKE(proj, *(i + n)), INVOKE(proj, *i)) == false.
Note

Complexity: O(Nlog(N)), where N = std::distance(first, last) comparisons.

comp has to induce a strict weak ordering on the values.

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 applies user-provided function objects.

• KeyIter: The type of the key iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• ValueIter: The type of the value iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• Comp: The type of the function/function object to use (deduced).

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• key_first: Refers to the beginning of the sequence of key elements the algorithm will be applied to.

• key_last: Refers to the end of the sequence of key elements the algorithm will be applied to.

• value_first: Refers to the beginning of the sequence of value elements the algorithm will be applied to, the range of elements must match [key_first, key_last)

• comp: comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator.

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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.

Return

The sort_by-key algorithm returns a hpx::future<tagged_pair<tag::in1(KeyIter>, tag::in2(ValueIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns otherwise. The algorithm returns a pair holding an iterator pointing to the first element after the last element in the input key sequence and an iterator pointing to the first element after the last element in the input value sequence.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename RandomIt, typename Sentinel, typename Proj = util::projection_identity, typename Compare = detail::less>
util::detail::algorithm_result<ExPolicy, RandomIt>::type stable_sort(ExPolicy &&policy, RandomIt first, Sentinel last, Compare &&comp = Compare(), Proj &&proj = Proj())

Sorts the elements in the range [first, last) in ascending order. The relative order of equal elements is preserved. The function uses the given comparison function object comp (defaults to using operator<()).

A sequence is sorted with respect to a comparator

comp and a projection proj if for every iterator i pointing to the sequence and every non-negative integer n such that i + n is a valid iterator pointing to an element of the sequence, and INVOKE(comp, INVOKE(proj, *(i + n)), INVOKE(proj, *i)) == false.
Note

Complexity: O(Nlog(N)), where N = std::distance(first, last) comparisons.

comp has to induce a strict weak ordering on the values.

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 applies user-provided function objects.

• RandomIt: The type of the source iterators used (deduced). This iterator type must meet the requirements of a random access iterator.

• Sentinel: The type of the end iterators used (deduced). This iterator type must meet the requirements of a random access iterator and must be a valid sentinel type for RandomIt.

• Comp: The type of the function/function object to use (deduced).

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• comp: comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator.

• proj: Specifies the function (or function object) which will be invoked for each pair of elements as a projection operation before the actual predicate comp is invoked.

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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.

Return

The stable_sort algorithm returns a hpx::future<RandomIt> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns RandomIt otherwise. The algorithm returns an iterator pointing to the first element after the last element in the input sequence.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type swap_ranges(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2)

Exchanges elements between range [first1, last1) and another range starting at first2.

The swap operations in the parallel

swap_ranges algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first1 and last1

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 swap operations.

• FwdIter1: The type of the first range of iterators to swap (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the second range of iterators to swap (deduced). This iterator type must meet the requirements of an forward iterator.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the first sequence of elements the algorithm will be applied to.

• last1: Refers to the end of the first sequence of elements the algorithm will be applied to.

• first2: Refers to the beginning of the second sequence of elements the algorithm will be applied to.

The swap operations in the parallel swap_ranges 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.

Return

The swap_ranges algorithm returns a hpx::future<FwdIter2> if the execution policy is of type parallel_task_policy and returns FwdIter2 otherwise. The swap_ranges algorithm returns iterator to the element past the last element exchanged in the range beginning with first2.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::type transform(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F &&f)

Applies the given function f to the range [first, last) and stores the result in another range, beginning at dest.

The invocations of

f in the parallel transform algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly last - first applications of f

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 invocations of f.

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

• FwdIter2: The type of the iterator representing the destination range (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 transform 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.

• dest: Refers to the beginning of the destination range.

• f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type &a);


The signature does not need to have const&. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type. The type Ret must be such that an object of type FwdIter2 can be dereferenced and assigned a value of type Ret.

The invocations of f in the parallel transform 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.

Return

The transform algorithm returns a hpx::future<in_out_result<FwdIter1, FwdIter2> > if the execution policy is of type parallel_task_policy and returns in_out_result<FwdIter1, FwdIter2> otherwise. The transform algorithm returns a tuple holding an iterator referring to the first element after the input sequence and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename F>
util::detail::algorithm_result<ExPolicy, util::in_in_out_result<FwdIter1, FwdIter2, FwdIter3>>::type transform(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter3 dest, F &&f)

Applies the given function f to pairs of elements from two ranges: one defined by [first1, last1) and the other beginning at first2, and stores the result in another range, beginning at dest.

The invocations of

f in the parallel transform algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly last - first applications of f

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 invocations of f.

• FwdIter1: The type of the source iterators for the first range used (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the source iterators for the second range used (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter3: The type of the iterator representing the destination range (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 transform requires F to meet the requirements of CopyConstructible.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the first sequence of elements the algorithm will be applied to.

• last1: Refers to the end of the first sequence of elements the algorithm will be applied to.

• first2: Refers to the beginning of the second sequence of elements the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

• f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type2 &b);


The signature does not need to have const&. The types

Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively. The type Ret must be such that an object of type FwdIter3 can be dereferenced and assigned a value of type Ret.

The invocations of f in the parallel transform 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.

Return

The transform algorithm returns a hpx::future<in_in_out_result<FwdIter1, FwdIter2, FwdIter3> > if the execution policy is of type parallel_task_policy and returns in_in_out_result<FwdIter1, FwdIter2, FwdIter3> otherwise. The transform algorithm returns a tuple holding an iterator referring to the first element after the first input sequence, an iterator referring to the first element after the second input sequence, and the output iterator referring to the element in the destination range, one past the last element copied.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T, typename Op, typename Conv>
util::detail::algorithm_result<ExPolicy, FwdIter2>::type transform_exclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T init, Op &&op, Conv &&conv)

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, conv(*first), …, conv(*(first + (i - result) - 1))).

The reduce operations in the parallel

transform_exclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicates op and conv.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• Conv: The type of the unary function object used for the conversion operation.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

• Op: The type of the binary function object used for the reduction operation.

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.

• dest: Refers to the beginning of the destination range.

• conv: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

R fun(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

• init: The initial value for the generalized sum.

• op: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.

The reduce operations in the parallel transform_exclusive_scan 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.

Neither

conv nor op shall invalidate iterators or subranges, or modify elements in the ranges [first,last) or [result,result + (last - first)).
Return

The transform_exclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The transform_exclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:

• a1 when N is 1

• op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN) where 1 < K+1 = M <= N.

The behavior of transform_exclusive_scan may be non-deterministic for a non-associative predicate.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Op, typename Conv, typename T>
util::detail::algorithm_result<ExPolicy, FwdIter2>::type transform_inclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op, Conv &&conv, T init)

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, init, conv(*first), …, conv(*(first + (i - result)))).

The reduce operations in the parallel

transform_inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• Conv: The type of the unary function object used for the conversion operation.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

• Op: The type of the binary function object used for the reduction operation.

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.

• dest: Refers to the beginning of the destination range.

• conv: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

R fun(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

• init: The initial value for the generalized sum.

• op: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.

The reduce operations in the parallel transform_inclusive_scan 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.

Neither

conv nor op shall invalidate iterators or subranges, or modify elements in the ranges [first,last) or [result,result + (last - first)).
Return

The transform_inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The transform_inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:

• a1 when N is 1

• op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.

The difference between exclusive_scan and transform_inclusive_scan is that transform_inclusive_scan includes the ith input element in the ith sum. If op is not mathematically associative, the behavior of transform_inclusive_scan may be non-deterministic.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Conv, typename Op>
util::detail::algorithm_result<ExPolicy, FwdIter2>::type transform_inclusive_scan(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op, Conv &&conv)

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, conv(*first), …, conv(*(first + (i - result)))).

The reduce operations in the parallel

transform_inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• Conv: The type of the unary function object used for the conversion operation.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

• Op: The type of the binary function object used for the reduction operation.

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.

• dest: Refers to the beginning of the destination range.

• conv: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

R fun(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

• op: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.

The reduce operations in the parallel transform_inclusive_scan 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.

Neither

conv nor op shall invalidate iterators or subranges, or modify elements in the ranges [first,last) or [result,result + (last - first)).
Return

The transform_inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The transform_inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.

Note

GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:

• a1 when N is 1

• op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.

The difference between exclusive_scan and transform_inclusive_scan is that transform_inclusive_scan includes the ith input element in the ith sum.

namespace hpx

Functions

template<typename ExPolicy, typename FwdIter, typename T, typename Reduce, typename Convert>
util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, FwdIter first, FwdIter last, T init, Reduce &&red_op, Convert &&conv_op)

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The reduce operations in the parallel

transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

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 input iterator.

• F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.

• T: The type of the value to be used as initial (and intermediate) values (deduced).

• Reduce: The type of the binary function object used for the reduction operation.

• Convert: The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

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.

• conv_op: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

R fun(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

• init: The initial value for the generalized sum.

• red_op: Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:

Ret fun(const Type1 &a, const Type2 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.

The reduce operations in the parallel transform_reduce 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.

The difference between

transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.
Return

The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type parallel_task_policy and returns T otherwise. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

• a1 when N is 1

• op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

• b1, …, bN may be any permutation of a1, …, aN and

• 1 < K+1 = M <= N.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T>
util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, T init)

Returns the result of accumulating init with the inner products of the pairs formed by the elements of two ranges starting at first1 and first2.

The operations in the parallel

transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op2.

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.

• FwdIter1: The type of the first source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the second source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to be used as return) values (deduced).

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the first sequence of elements the result will be calculated with.

• last1: Refers to the end of the first sequence of elements the algorithm will be applied to.

• first2: Refers to the beginning of the second sequence of elements the result will be calculated with.

• init: The initial value for the sum.

The operations in the parallel transform_reduce 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.

Return

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

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T, typename Reduce, typename Convert>
util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, T init, Reduce &&red_op, Convert &&conv_op)

Returns the result of accumulating init with the inner products of the pairs formed by the elements of two ranges starting at first1 and first2.

The operations in the parallel

transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: O(last - first) applications of the predicate op2.

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.

• FwdIter1: The type of the first source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

• FwdIter2: The type of the second source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

• T: The type of the value to be used as return) values (deduced).

• Reduce: The type of the binary function object used for the multiplication operation.

• Convert: The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first1: Refers to the beginning of the first sequence of elements the result will be calculated with.

• last1: Refers to the end of the first sequence of elements the algorithm will be applied to.

• first2: Refers to the beginning of the second sequence of elements the result will be calculated with.

• init: The initial value for the sum.

• red_op: Specifies the function (or function object) which will be invoked for the initial value and each of the return values of op2. This is a binary predicate. The signature of this predicate should be equivalent to should be equivalent to:

Ret fun(const Type1 &a, const Type1 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Ret must be such that it can be implicitly converted to a type of T.

• conv_op: Specifies the function (or function object) which will be invoked for each of the input values of the sequence. This is a binary predicate. The signature of this predicate should be equivalent to

Ret fun(const Type1 &a, const Type2 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Ret must be such that it can be implicitly converted to an object for the second argument type of op1.

The operations in the parallel transform_reduce 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.

Return

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

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type uninitialized_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)

Copies the elements in the range, defined by [first, last), to an uninitialized memory area beginning at dest. If an exception is thrown during the copy operation, the function has no effects.

The assignments in the parallel

uninitialized_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.

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.

• dest: Refers to the beginning of the destination range.

The assignments in the parallel uninitialized_copy 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.

Return

The uninitialized_copy algorithm returns a hpx::future<FwdIter2>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The uninitialized_copy algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type uninitialized_copy_n(ExPolicy &&policy, FwdIter1 first, Size count, FwdIter2 dest)

Copies the elements in the range [first, first + count), starting from first and proceeding to first + count - 1., to another range beginning at dest. If an exception is thrown during the copy operation, the function has no effects.

The assignments in the parallel

uninitialized_copy_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.

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.

• FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.

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 starting at first the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

The assignments in the parallel uninitialized_copy_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.

Return

The uninitialized_copy_n algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The uninitialized_copy_n algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter>
util::detail::algorithm_result<ExPolicy>::type uninitialized_default_construct(ExPolicy &&policy, FwdIter first, FwdIter last)

Constructs objects of type typename iterator_traits<ForwardIt>::value_type in the uninitialized storage designated by the range [first, last) by default-initialization. If an exception is thrown during the initialization, the function has no effects.

The assignments in the parallel

uninitialized_default_construct algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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 an forward iterator.

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.

The assignments in the parallel uninitialized_default_construct 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.

Return

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

template<typename ExPolicy, typename FwdIter, typename Size>
util::detail::algorithm_result<ExPolicy, FwdIter>::type uninitialized_default_construct_n(ExPolicy &&policy, FwdIter first, Size count)

Constructs objects of type typename iterator_traits<ForwardIt>::value_type in the uninitialized storage designated by the range [first, first + count) by default-initialization. If an exception is thrown during the initialization, the function has no effects.

The assignments in the parallel

uninitialized_default_construct_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.

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.

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 starting at first the algorithm will be applied to.

The assignments in the parallel uninitialized_default_construct_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.

Return

The uninitialized_default_construct_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. The uninitialized_default_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter, typename T>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy>::type>::type uninitialized_fill(ExPolicy &&policy, FwdIter first, FwdIter last, T const &value)

Copies the given value to an uninitialized memory area, defined by the range [first, last). If an exception is thrown during the initialization, the function has no effects.

The initializations in the parallel

uninitialized_fill algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last

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.

• T: The type of the value to be assigned (deduced).

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.

• value: The value to be assigned.

The initializations in the parallel uninitialized_fill 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.

Return

The uninitialized_fill algorithm returns a hpx::future<void>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns nothing otherwise.

template<typename ExPolicy, typename FwdIter, typename Size, typename T>
std::enable_if<hpx::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy>::type>::type uninitialized_fill_n(ExPolicy &&policy, FwdIter first, Size count, T const &value)

Copies the given value value to the first count elements in an uninitialized memory area beginning at first. If an exception is thrown during the initialization, the function has no effects.

The initializations in the parallel

uninitialized_fill_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.

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.

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

• T: The type of the value to be assigned (deduced).

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 starting at first the algorithm will be applied to.

• value: The value to be assigned.

The initializations in the parallel uninitialized_fill_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.

Return

The uninitialized_fill_n algorithm returns a hpx::future<void>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns nothing otherwise.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, FwdIter2>::type uninitialized_move(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)

Moves the elements in the range, defined by [first, last), to an uninitialized memory area beginning at dest. If an exception is thrown during the initialization, some objects in [first, last) are left in a valid but unspecified state.

The assignments in the parallel

uninitialized_move algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first move operations.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.

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.

• dest: Refers to the beginning of the destination range.

The assignments in the parallel uninitialized_move 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.

Return

The uninitialized_move algorithm returns a hpx::future<FwdIter2>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The uninitialized_move algorithm returns the output iterator to the element in the destination range, one past the last element moved.

template<typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type uninitialized_move_n(ExPolicy &&policy, FwdIter1 first, Size count, FwdIter2 dest)

Moves the elements in the range [first, first + count), starting from first and proceeding to first + count - 1., to another range beginning at dest. If an exception is thrown during the initialization, some objects in [first, first + count) are left in a valid but unspecified state.

The assignments in the parallel

uninitialized_move_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count movements, if count > 0, no move operations otherwise.

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.

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 starting at first the algorithm will be applied to.

• dest: Refers to the beginning of the destination range.

The assignments in the parallel uninitialized_move_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.

Return

The uninitialized_move_n algorithm returns a hpx::future<std::pair<FwdIter1, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns std::pair<FwdIter1, FwdIter2> otherwise. The uninitialized_move_n algorithm returns the pair of the input iterator to the element past in the source range and an output iterator to the element in the destination range, one past the last element moved.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter>
util::detail::algorithm_result<ExPolicy>::type uninitialized_value_construct(ExPolicy &&policy, FwdIter first, FwdIter last)

Constructs objects of type typename iterator_traits<ForwardIt>::value_type in the uninitialized storage designated by the range [first, last) by default-initialization. If an exception is thrown during the initialization, the function has no effects.

The assignments in the parallel

uninitialized_value_construct algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first 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 an forward iterator.

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.

The assignments in the parallel uninitialized_value_construct 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.

Return

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

template<typename ExPolicy, typename FwdIter, typename Size>
util::detail::algorithm_result<ExPolicy, FwdIter>::type uninitialized_value_construct_n(ExPolicy &&policy, FwdIter first, Size count)

Constructs objects of type typename iterator_traits<ForwardIt>::value_type in the uninitialized storage designated by the range [first, first + count) by default-initialization. If an exception is thrown during the initialization, the function has no effects.

The assignments in the parallel

uninitialized_value_construct_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.

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.

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 starting at first the algorithm will be applied to.

The assignments in the parallel uninitialized_value_construct_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.

Return

The uninitialized_value_construct_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. The uninitialized_value_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename FwdIter, typename Pred = detail::equal_to, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type unique(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred = Pred(), Proj &&proj = Proj())

Eliminates all but the first element from every consecutive group of equivalent elements from the range [first, last) and returns a past-the-end iterator for the new logical end of the range.

The assignments in the parallel

unique algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first - 1 applications of the predicate pred and no more than twice as many applications of the projection proj.

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.

• Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• pred: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

bool pred(const Type1 &a, const Type2 &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The types

Type1 and Type2 must be such that objects of types FwdIter can be dereferenced and then implicitly converted to both Type1 and Type2

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel unique 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.

Return

The unique algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The unique algorithm returns the iterator to the new end of the range.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type unique_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Pred &&pred = Pred(), Proj &&proj = Proj())

Copies the elements from the range [first, last), to another range beginning at dest in such a way that there are no consecutive equal elements. Only the first element of each group of equal elements is copied.

The assignments in the parallel

unique_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Performs not more than last - first assignments, exactly last - first - 1 applications of the predicate pred and no more than twice as many applications of the projection proj

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.

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

• FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.

• Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique_copy requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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.

• dest: Refers to the beginning of the destination range.

• pred: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

bool pred(const Type &a, const Type &b);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The assignments in the parallel unique_copy 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.

Return

The unique_copy algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The unique_copy algorithm returns the pair of the source iterator to last, and the destination iterator to the end of the dest range.

namespace hpx
namespace ranges

Functions

template<typename FwdIter, typename Sent, typename Proj = hpx::parallel::util::projection_identity, typename Pred = detail::equal_to>
FwdIter adjacent_find(FwdIter first, Sent last, Pred &&pred = Pred(), Proj &&proj = Proj())

Searches the range [first, last) for two consecutive identical elements.

Note

Complexity: Exactly the smaller of (result - first) + 1 and (last - first) - 1 application of the predicate where result is the value returned

Return

The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

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

• Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

• Pred: The type of an optional function/function object to use.

Parameters
• first: Refers to the beginning of the sequence of elements of the range the algorithm will be applied to.

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

• pred: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1 .

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

template<typename ExPolicy, typename FwdIter, typename Sent, typename Proj = hpx::parallel::util::projection_identity, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter>::type adjacent_find(ExPolicy &&policy, FwdIter first, Sent last, Pred &&pred = Pred(), Proj &&proj = Proj())

Searches the range [first, last) for two consecutive identical elements. This version uses the given binary predicate pred

The comparison operations in the parallel

adjacent_find invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly the smaller of (result - first) + 1 and (last - first) - 1 application of the predicate where result is the value returned

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 for the range (deduced). This iterator type must meet the requirements of an forward iterator.

• Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

Parameters
• policy: The execution policy to use for the scheduling of the iterations.

• first: Refers to the beginning of the sequence of elements of the range the algorithm will be applied to.

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

• pred: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1 .

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The comparison operations in the parallel adjacent_find 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.

adjacent_find is available if the user decides to provide their algorithm their own binary predicate pred.
Return

The adjacent_find algorithm returns a hpx::future<InIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns InIter otherwise. The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

template<typename Rng, typename Proj = hpx::parallel::util::projection_identity, typename Pred = detail::equal_to>
hpx::traits::range_traits<Rng>::iterator_type adjacent_find(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Searches the range rng for two consecutive identical elements.

Note

Complexity: Exactly the smaller of (result - std::begin(rng)) + 1 and (std::begin(rng) - std::end(rng)) - 1 applications of the predicate where result is the value returned

Return

The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

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.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

• Pred: The type of an optional function/function object to use.

Parameters
• rng: Refers to the sequence of elements the algorithm will be applied to.

• pred: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1 .

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

template<typename ExPolicy, typename Rng, typename Proj = hpx::parallel::util::projection_identity, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_type>::type adjacent_find(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Searches the range rng for two consecutive identical elements.

The comparison operations in the parallel

adjacent_find invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: Exactly the smaller of (result - std::begin(rng)) + 1 and (std::begin(rng) - std::end(rng)) - 1 applications of the predicate where result is the value returned

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.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

• Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

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.

• pred: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:

bool pred(const Type1 &a, const Type1 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types

Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1 .

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The comparison operations in the parallel adjacent_find 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.

adjacent_find is available if the user decides to provide their algorithm their own binary predicate pred.
Return

The adjacent_find algorithm returns a hpx::future<InIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns InIter otherwise. The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

namespace hpx
namespace ranges

Functions

template<typename ExPolicy, typename Rng, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type none_of(ExPolicy &&policy, Rng &&rng, F &&f, Proj &&proj = Proj())

Checks if unary predicate f returns true for no elements in the range rng.

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most std::distance(begin(rng), end(rng)) applications of the predicate f

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 applies user-provided function objects.

• Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

• F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of none_of requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The application of function objects in parallel 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.

Return

The none_of algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The none_of algorithm returns true if the unary predicate f returns true for no elements in the range, false otherwise. It returns true if the range is empty.

template<typename ExPolicy, typename Rng, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type any_of(ExPolicy &&policy, Rng &&rng, F &&f, Proj &&proj = Proj())

Checks if unary predicate f returns true for at least one element in the range rng.

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most std::distance(begin(rng), end(rng)) applications of the predicate f

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 applies user-provided function objects.

• Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

• F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of none_of requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

The application of function objects in parallel 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.

Return

The any_of algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The any_of algorithm returns true if the unary predicate f returns true for at least one element in the range, false otherwise. It returns false if the range is empty.

template<typename ExPolicy, typename Rng, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type all_of(ExPolicy &&policy, Rng &&rng, F &&f, Proj &&proj = Proj())

Checks if unary predicate f returns true for all elements in the range rng.

The application of function objects in parallel algorithm invoked with an execution policy object of type

sequenced_policy execute in sequential order in the calling thread.
Note

Complexity: At most std::distance(begin(rng), end(rng)) applications of the predicate f

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 applies user-provided function objects.

• Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

• F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of none_of requires F to meet the requirements of CopyConstructible.

• Proj: The type of an optional projection function. This defaults to util::projection_identity

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: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

bool pred(const Type &a);


The signature does not need to have const&, but the function must not modify the objects passed to it. The type

Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

• proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate