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

Typedefs

template<typename Source, typename Dest>
using pointer_copy_category_t = typename pointer_copy_category<Source, Dest>::type
template<typename Source, typename Dest>
using pointer_move_category_t = typename pointer_move_category<Source, Dest>::type
template<typename Iterator>
using remove_const_iterator_value_type_t = typename remove_const_iterator_value_type<Iterator>::type
struct general_pointer_tag

Subclassed by hpx::traits::trivially_copyable_pointer_tag

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

Public Types

template<>
using type = typename detail::pointer_copy_category::type
template<typename Source, typename Dest, typename Enable = void>
struct pointer_move_category

Public Types

template<>
using type = typename detail::pointer_move_category::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

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

Public Types

template<>
using type = typename std::decay<Iterator>::type::proxy_type
namespace hpx
namespace parallel
namespace traits

Typedefs

template<typename F, typename Iter>
using is_projected_t = typename is_projected<F, Iter>::type
template<typename ExPolicy, typename F, typename ...Projected>
using is_indirect_callable_t = typename is_indirect_callable<ExPolicy, F, Projected...>::type

Variables

template<typename F, typename Iter>HPX_INLINE_CONSTEXPR_VARIABLE bool hpx::parallel::traits::is_projected_v=is_projected<F, Iter>::value
template<typename ExPolicy, typename F, typename... Projected>HPX_INLINE_CONSTEXPR_VARIABLE bool hpx::parallel::traits::is_indirect_callable_v=is_indirect_callable<ExPolicy, F, Projected...>::value
template<typename Proj, typename Iter>
struct projected

Public Types

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

Public Types

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

Public Types

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

Public Types

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

Public Types

template<>
using projector_type = typename std::decay<Proj>::type
template<>
using iterator_type = typename hpx::traits::range_iterator<Rng>::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

template<>
using projector_type = typename std::decay<Proj>::type
template<>
using iterator_type = typename hpx::traits::range_iterator<Rng>::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>
hpx::future<void> 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.

Postcondition: All tasks spawned from

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 ExPolicy, typename F>
void define_task_block(ExPolicy &&policy, F &&f)
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.

Postcondition: All tasks spawned from

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.

Postcondition: All tasks spawned from

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.

Postcondition: All tasks spawned from

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
#include <task_block.hpp>

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.

A task_block

is active if it was created by the nearest enclosing task block, where “task block” refers to an invocation of define_task_block or define_task_block_restore_thread and “nearest

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:
    define_task_block([&](auto& tr) {
        tr.run([&] {
            tr.run([] { f(); });                // Error: tr is not active
            define_task_block([&](auto& tr) {   // Nested task block
                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

template<>
using execution_policy = ExPolicy

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
  • This: function may throw task_canceled_exception, as described in Exception Handling. The function will also throw a exception_list holding all exceptions that were caught while executing the tasks.

void wait()

Blocks until the tasks spawned using this task_block have finished.

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:
    define_task_block([&](auto& tr) {
        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
  • This: function may throw task_canceled_exception, as described in Exception Handling. The function will also throw a exception_list holding all exceptions that were caught while executing the tasks.

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

hpx::execution::experimental::task_group tasks_
threads::thread_id_type id_
ExPolicy policy_
class task_canceled_exception : public exception
#include <task_block.hpp>

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 execution
namespace experimental
class task_group

Public Functions

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

Spawns a task to compute f() and returns immediately.

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

Waits for all tasks in the group to complete.

void add_exception(std::exception_ptr p)

Private Members

hpx::lcos::local::latch latch_
hpx::exception_list errors_
bool has_arrived_
struct on_exit

Public Functions

on_exit(hpx::lcos::local::latch &l)
~on_exit()
on_exit(on_exit const &rhs)
on_exit &operator=(on_exit const &rhs)
on_exit(on_exit &&rhs)
on_exit &operator=(on_exit &&rhs)

Public Members

hpx::lcos::local::latch *latch_
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.

This overload of

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.

This overload of

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.

This overload of

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(std::decay_t<I> 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, std::decay_t<I> 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(std::decay_t<I> 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, std::decay_t<I> 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

Functions

template<typename InIter1, typename InIter2, typename Pred>
bool lexicographical_compare(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, 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 without an execution policy object 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
  • InIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an input iterator.

  • InIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an input 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
  • 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

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 returns bool if the execution policy object is not passed in. The lexicographically_compare algorithm returns true if the first range is lexicographically less, otherwise it returns false. range [first2, last2), it returns false.

template<typename FwdIter1, typename FwdIter2, typename Pred>
util::detail::algorithm_result<ExPolicy, bool>::type lexicographical_compare(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, 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

Functions

template<typename InIter, typename OutIter, typename T>
FwdIter remove_copy(InIter first, InIter last, OutIter dest, T const &value)

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 value. 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: *it == value

The assignments in the parallel

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

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

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

  • T: The type that the result of dereferencing FwdIter1 is compared to.

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.

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

  • val: Value to be removed.

Return

The remove_copy algorithm returns an OutIter. The remove_copy algorithm returns the iterator to the element past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T>
FwdIter remove_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T const &val)

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 value. 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: *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.

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.

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<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The remove_copy algorithm returns the iterator to the element past the last element copied.

template<typename InIter, typename OutIter, typename Pred>
FwdIter remove_copy_if(InIter first, InIter last, OutIter 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 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, *it) != false.

The assignments in the parallel

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

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

  • OutIter: The type of the iterator representing the destination range (deduced).

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

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.

  • 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 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 InIter can be dereferenced and then implicitly converted to Type.

Return

The remove_copy_if algorithm returns an OutIter The remove_copy_if algorithm returns the iterator to the element past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred>
FwdIter remove_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 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, *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.

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

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

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<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The remove_copy_if algorithm returns the iterator to the element past the last element copied.

namespace hpx

Functions

template<typename Initer, typename T>
void replace(InIter first, InIter last, T const &old_value, T const &new_value)

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: *it == old_value

The assignments in the parallel

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

Complexity: Performs exactly last - first assignments.

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

  • T: The type of the old and new values to replace (deduced).

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.

  • old_value: Refers to the old value of the elements to replace.

  • new_value: Refers to the new value to use as the replacement.

Return

The replace algorithm returns a void.

template<typename ExPolicy, typename FwdIter, typename T>
parallel::util::detail::algorithm_result<ExPolicy, void>::type replace(ExPolicy &&policy, FwdIter first, FwdIter last, T const &old_value, T const &new_value)

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

  • T: The type of the old and new values to replace (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.

  • old_value: Refers to the old value of the elements to replace.

  • new_value: Refers to the new value to use as the replacement.

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<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise.

template<typename Iter, typename Pred, typename T>
void replace_if(Iter first, Iter last, Pred &&pred, T const &new_value)

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, *it) != false

The assignments in the parallel

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

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

Template Parameters
  • Iter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.

  • Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires Pred to meet the requirements of CopyConstructible. (deduced).

  • T: The type of the new values to replace (deduced).

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 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 InIter can be dereferenced and then implicitly converted to Type.

  • new_value: Refers to the new value to use as the replacement.

Return

The replace_if algorithm returns void.

template<typename ExPolicy, typename FwdIter, typename Pred, typename T>
parallel::util::detail::algorithm_result<ExPolicy, void>::type replace_if(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred, T const &new_value)

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

  • Pred: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires Pred to meet the requirements of CopyConstructible. (deduced).

  • T: The type of the new values to replace (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.

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

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<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise.

template<typename InIter, typename OutIter, typename T>
OutIter replace_copy(InIter first, InIter last, OutIter dest, T const &old_value, T const &new_value)

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: *(first + (i - result)) == old_value

The assignments in the parallel

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

Complexity: Performs exactly last - first applications of the predicate. of the algorithm may be parallelized and the manner in which it executes the assignments.

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

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

  • T: The type of the old and new values (deduced).

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.

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

Return

The replace_copy algorithm returns an OutIter The replace_copy algorithm returns the Iterator to the element past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::type replace_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T const &old_value, T const &new_value)

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: *(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.

  • T: The type of the old and new 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.

  • old_value: Refers to the old value of the elements to replace.

  • new_value: Refers to the new value to use as the replacement.

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<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The replace_copy algorithm returns the Iterator to the element past the last element copied.

template<typename InIter, typename OutIter, typename Pred, typename T>
OutIter replace_copy_if(InIter first, InIter last, OutIter dest, Pred &&pred, T const &new_value)

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, *(first + (i - result))) != false

The assignments in the parallel

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

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

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

  • OutIter: 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 the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires Pred to meet the requirements of CopyConstructible. (deduced).

  • T: The type of the new values to replace (deduced).

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.

  • 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 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 InIter can be dereferenced and then implicitly converted to Type.

  • new_value: Refers to the new value to use as the replacement.

Return

The replace_copy_if algorithm returns an OutIter. The replace_copy_if algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred, typename T>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::type replace_copy_if(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Pred &&pred, T const &new_value)

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, *(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 a forward iterator.

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

  • Pred: 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).

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

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<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The replace_copy_if algorithm returns the iterator to the element in the destination range, one past the last element copied.

namespace hpx

Functions

template<typename BidirIter>
void reverse(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 execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last.

Template Parameters
  • BidirIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an bidirectional iterator.

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.

Return

The reverse algorithm returns a void.

template<typename ExPolicy, typename BidirIter>
parallel::util::detail::algorithm_result<ExPolicy, void>::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<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise.

template<typename BidirIter, typename OutIter>
OutIter reverse_copy(BidirIter first, BidirIter last, Outiter dest)

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 execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

Template Parameters
  • BidirIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an bidirectional iterator.

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

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.

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

Return

The reverse_copy algorithm returns an OutIter. The reverse_copy algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename BidirIter, typename FwdIter>
util::detail::algorithm_result<ExPolicy, 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: 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<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The reverse_copy 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, 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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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

Functions

template<typename InIter, typename FwdIter>
FwdIter uninitialized_copy(InIter first, InIter last, FwdIter 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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

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

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

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.

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

Return

The uninitialized_copy algorithm returns FwdIter. 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 FwdIter2>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::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 InIter, typename Size, typename FwdIter>
FwdIter uninitialized_copy_n(InIter first, Size count, FwdIter 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 without an execution policy object execute in sequential order in the calling thread.
Note

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

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

Return

The uninitialized_copy_n algorithm returns a returns FwdIter2. The uninitialized_copy_n 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>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::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

Functions

template<typename FwdIter>
void uninitialized_default_construct(FwdIter first, FwdIter last)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range 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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

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

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.

Return

The uninitialized_default_construct algorithm returns nothing

template<typename ExPolicy, typename FwdIter>
parallel::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 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 nothing otherwise.

template<typename FwdIter, typename Size>
FwdIter uninitialized_default_construct_n(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 without an execution policy object execute in sequential order in the calling thread.
Note

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

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

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

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.

Return

The uninitialized_default_construct_n algorithm returns a returns FwdIter. The uninitialized_default_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

template<typename ExPolicy, typename FwdIter, typename Size>
parallel::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

Functions

template<typename FwdIter, typename T>
void uninitialized_fill(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 assignments in the parallel

uninitialized_fill algorithm invoked without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last

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 be assigned (deduced).

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: The value to be assigned.

Return

The uninitialized_fill algorithm returns nothing

template<typename ExPolicy, typename FwdIter, typename T>
parallel::util::detail::algorithm_result<ExPolicy>::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 FwdIter, typename Size, typename T>
FwdIter uninitialized_fill_n(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 assignments in the parallel

uninitialized_fill_n algorithm invoked without an execution policy object execute in sequential order in the calling thread.
Note

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

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

Return

The uninitialized_fill_n algorithm returns a returns FwdIter. The uninitialized_fill_n algorithm returns the output iterator to the element in the range, one past the last element copied.

template<typename ExPolicy, typename FwdIter, typename Size, typename T>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::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<FwdIter>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The uninitialized_fill_n algorithm returns the output iterator to the element in the range, one past the last element copied.

namespace hpx

Functions

template<typename InIter, typename FwdIter>
FwdIter uninitialized_move(InIter first, InIter last, FwdIter 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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

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

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

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.

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

Return

The uninitialized_move algorithm returns FwdIter. 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 FwdIter2>
parallel::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 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_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 InIter, typename Size, typename FwdIter>
FwdIter uninitialized_move_n(InIter first, Size count, FwdIter 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
  • 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
  • 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.

Return

The uninitialized_move_n algorithm returns a returns FwdIter2. The uninitialized_move_n 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>
parallel::util::detail::algorithm_result<ExPolicy, 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 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_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<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The uninitialized_move_n algorithm returns the output iterator to the element in the destination range, one past the last element moved.

namespace hpx

Functions

template<typename FwdIter>
void uninitialized_value_construct(FwdIter first, FwdIter last)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range by value-initialization. If an exception is thrown during the initialization, the function has no effects.

The assignments in the parallel

uninitialized_value_construct algorithm invoked without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

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

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.

Return

The uninitialized_value_construct algorithm returns nothing

template<typename ExPolicy, typename FwdIter>
parallel::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 by value-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 nothing otherwise.

template<typename FwdIter, typename Size>
FwdIter uninitialized_value_construct_n(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 value-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 without an execution policy object execute in sequential order in the calling thread.
Note

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

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

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

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.

Return

The uninitialized_value_construct_n algorithm returns a returns FwdIter. The uninitialized_value_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

template<typename ExPolicy, typename FwdIter, typename Size>
parallel::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 value-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.

This overload of

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.

This overload of

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

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename FwdIter>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_result<Iter1, Iter>>::type copy(ExPolicy &&policy, Iter1 iter, Sent1 sent, FwdIter 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.

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

  • Sent1: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

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

  • sent: 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<ranges::copy_result<FwdIter1, FwdIter> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_result<FwdIter1, FwdIter> 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 Rng, typename FwdIter>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_result<typename hpx::traits::range_traits<Rng>::iterator_type, FwdIter>>::type copy(ExPolicy &&policy, Rng &&rng, FwdIter dest)

Copies the elements in the range rng 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 std::distance(begin(rng), end(rng)) assignments.

Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng: Refers to 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<ranges::copy_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_result<iterator_t<Rng>, 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, hpx::ranges::copy_n_result<FwdIter1, 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<ranges::copy_n_result<FwdIter1, FwdIter2> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_n_result<FwdIter1, 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 Sent1, typename FwdIter, typename F, typename Proj = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_if_result<typename hpx::traits::range_traits<Rng>::iterator_type, OutIter>>::type copy_if(ExPolicy &&policy, FwdIter1 iter, Sent1 sent, FwdIter 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 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 std::distance(begin(rng), end(rng)) assignments, exactly 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 executes the assignments.

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

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

  • FwdIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output 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.

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

  • sent: 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 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 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 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<ranges::copy_if_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_if_result<iterator_t<Rng>, FwdIter2> otherwise. The copy_if 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 Rng, typename OutIter, typename F, typename Proj = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_if_result<typename hpx::traits::range_traits<Rng>::iterator_type, OutIter>>::type copy_if(ExPolicy &&policy, Rng &&rng, OutIter dest, F &&f, Proj &&proj = Proj())

Copies the elements in the range rng 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 std::distance(begin(rng), end(rng)) assignments, exactly 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 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 input iterator.

  • OutIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output 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.

  • rng: Refers to 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 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 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 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<ranges::copy_if_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_if_result<iterator_t<Rng>, FwdIter2> otherwise. The copy_if 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.

namespace hpx
namespace ranges

Functions

template<typename ExPolicy, typename Rng, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<typename hpx::traits::range_traits<Rng>::iterator_type>::difference_type>::type count(ExPolicy &&policy, Rng &&rng, 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng: Refers to 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<FwdIter>::difference_type. The count algorithm returns the number of elements satisfying the given criteria.

template<typename ExPolicy, typename Rng, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<typename hpx::traits::range_traits<Rng>::iterator_type>::difference_type>::type count_if(ExPolicy &&policy, Rng &&rng, 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<FwdIter>::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.

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

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

  • 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
namespace ranges

Functions

template<typename ExPolicy>
util::detail::algorithm_result<ExPolicy, typename traits::range_iterator<Rng>::type>::type destroy(ExPolicy &&policy, Rng &&rng)

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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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.

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

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type equal(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

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

  • Sent1: The type of the source iterators used for the end of the first range (deduced).

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

  • Sent2: The type of the source iterators used for the end of the second range (deduced).

  • 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 applied to the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second range. This defaults to util::projection_identity

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

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

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

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 Rng1, typename Rng2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type equal(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Rng1: The type of the first source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • Rng2: The type of the second source range used (deduced). The iterators extracted from this range 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 applied to the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second range. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements 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

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

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

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

Functions

template<typename ExPolicy, typename Rng, typename T>
util::detail::algorithm_result<ExPolicy>::type fill(ExPolicy &&policy, Rng &&rng, T const &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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

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.

  • 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 Iterator, typename Size, typename T>
util::detail::algorithm_result<ExPolicy, Iterator>::type fill_n(ExPolicy &&policy, Iterator first, Size count, T const &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.

  • Iterator: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an 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 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
namespace ranges

Functions

template<typename ExPolicy, typename Iter, typename Sent, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, Iter>::type find(ExPolicy &&policy, Iter first, Sent last, T const &val, Proj &&proj = Proj())

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.

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

  • Sent: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter.

  • T: The type of the value to find (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 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

  • 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 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 Rng, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, Iter>::type find(ExPolicy &&policy, Rng &&rng, T const &val, Proj &&proj = Proj())

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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • T: The type of the value to find (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.

  • rng: Refers to the sequence of elements the algorithm will be applied to.

  • val: the value to compare the elements to

  • 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 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 Iter1, typename Sent1, typename Iter2, typename Sent2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng1>::type>::type find_end(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

Returns the last subsequence of elements [first2, last2) found in the range [first1, last1) 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.

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

  • Sent1: The type of the end source iterators for the first sequence used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

  • Sent2: The type of the end source iterators for the second sequence used (deduced). This iterator type must meet the requirements of an sentinel for Iter2.

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

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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.

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

  • 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 iterator_t<Rng> and iterator_t<Rng2> 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 the first range of type dereferenced iterator_t<Rng1> 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 the second range of type dereferenced iterator_t<Rng2> as a projection operation before the function op 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.

This overload of

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

The find_end algorithm returns a hpx::future<iterator_t<Rng> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns iterator_t<Rng> otherwise. The find_end algorithm returns an iterator to the beginning of the last subsequence rng2 in range rng. If the length of the subsequence rng2 is greater than the length of the range rng, end(rng) is returned. Additionally if the size of the subsequence is empty or no subsequence is found, end(rng) is also returned.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng1>::type>::type find_end(ExPolicy &&policy, Rng1 &&rng, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

Returns the last subsequence of elements rng2 found in the range rng 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(begin(rng2), end(rng2)) and N = distance(begin(rng), end(rng)).

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.

  • Rng1: The type of the first source range (deduced). The iterators extracted from this range type must meet the requirements of a forward iterator.

  • Rng2: The type of the second source range (deduced). The iterators extracted from this range 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 replace requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements the algorithm will be applied to.

  • 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 iterator_t<Rng> and iterator_t<Rng2> 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 the first range of type dereferenced iterator_t<Rng1> 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 the second range of type dereferenced iterator_t<Rng2> as a projection operation before the function op 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.

This overload of

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

The find_end algorithm returns a hpx::future<iterator_t<Rng> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns iterator_t<Rng> otherwise. The find_end algorithm returns an iterator to the beginning of the last subsequence rng2 in range rng. If the length of the subsequence rng2 is greater than the length of the range rng, end(rng) is returned. Additionally if the size of the subsequence is empty or no subsequence is found, end(rng) is also returned.

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng1>::type>::type find_first_of(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

Searches the range [first1, last1) for any elements in the range [first2, last2). 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(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.

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

  • Sent1: The type of the end source iterators for the first sequence used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

  • Sent2: The type of the end source iterators for the second sequence used (deduced). This iterator type must meet the requirements of an sentinel for Iter2.

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

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

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

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.

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

  • 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 iterator_t<Rng1> and iterator_t<Rng2> 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 iterator_t<Rng1> 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 iterator_t<Rng2> 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.

This overload of

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

The find_end algorithm returns a hpx::future<iterator_t<Rng1> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns iterator_t<Rng1> otherwise. The find_first_of algorithm returns an iterator to the first element in the range rng1 that is equal to an element from the range rng2. If the length of the subsequence rng2 is greater than the length of the range rng1, end(rng1) is returned. Additionally if the size of the subsequence is empty or no subsequence is found, end(rng1) is also returned.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng1>::type>::type find_first_of(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

Searches the range rng1 for any elements in the range rng2. 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(begin(rng2), end(rng2)) and N = distance(begin(rng1), end(rng1)).

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.

  • Rng1: The type of the first source range (deduced). The iterators extracted from this range type must meet the requirements of a forward iterator.

  • Rng2: The type of the second source range (deduced). The iterators extracted from this range 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 replace 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 in rng1.

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

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

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

  • rng2: Refers to the second sequence of elements the algorithm will be applied to.

  • 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 iterator_t<Rng1> and iterator_t<Rng2> 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 iterator_t<Rng1> 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 iterator_t<Rng2> 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.

This overload of

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

The find_end algorithm returns a hpx::future<iterator_t<Rng1> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns iterator_t<Rng1> otherwise. The find_first_of algorithm returns an iterator to the first element in the range rng1 that is equal to an element from the range rng2. If the length of the subsequence rng2 is greater than the length of the range rng1, end(rng1) is returned. Additionally if the size of the subsequence is empty or no subsequence is found, end(rng1) is also returned.

namespace hpx
namespace ranges

Functions

template<typename InIter, typename Sent, typename F, typename Proj = util::projection_identity>
hpx::ranges::for_each_result<InIter, F> for_each(InIter first, Sent last, F &&f, Proj &&proj = Proj())

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.

Applies

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

{last, std::move(f)} where last is the iterator corresponding to the input sentinel last.

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

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

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

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

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

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

{first + count, std::move(f)}

Template Parameters
  • InIter: The type of the source begin 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). Unlike its sequential form, the parallel overload of for_each requires F to meet the requirements of CopyConstructible.

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

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

template<typename ExPolicy, typename FwdIter, typename Sent, typename F, typename Proj = util::projection_identity>
FwdIter for_each(ExPolicy &&policy, FwdIter first, Sent last, F &&f, Proj &&proj = Proj())

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.

Return

The for_each 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 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 begin iterator used (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.

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

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

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

template<typename Rng, typename F, typename Proj = util::projection_identity>
hpx::ranges::for_each_result<typename hpx::traits::range_iterator<Rng>::type, F> for_each(ExPolicy &&policy, Rng &&rng, F &&f, Proj &&proj = Proj())

Applies f to the result of dereferencing every iterator in the given range rng.

If

f returns a result, the result is ignored.
Note

Complexity: Applies f exactly size(rng) times.

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

Return

{std::end(rng), std::move(f)}

Template Parameters
  • 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 for_each 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:

    <ignored> pred(const Type &a);
    

    The signature does not need to have const&. 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.

template<typename ExPolicy, typename Rng, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type for_each(ExPolicy &&policy, Rng &&rng, F &&f, Proj &&proj = Proj())

Applies f to the result of dereferencing every iterator in the given range rng.

If

f returns a result, the result is ignored.
Note

Complexity: Applies f exactly size(rng) 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.

  • 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 for_each 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:

    <ignored> pred(const Type &a);
    

    The signature does not need to have const&. 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 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<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, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type for_each_n(ExPolicy &&policy, FwdIter first, Size count, F &&f, Proj &&proj = Proj())

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.

Return

The for_each 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 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 begin iterator 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.

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

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

namespace hpx
namespace ranges

Functions

template<typename Iter, typename Sent, typename ...Args>
void for_loop(Iter first, Sent last, Args&&... args)

The for_loop implements loop functionality over a range specified by iterator bounds. 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:

Iter shall 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
  • Iter: The type of the iteration variable (input iterator).

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for Iter.

  • 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(Iter 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 Iter, typename Sent, typename ...Args>
util::detail::algorithm_result<ExPolicy>::type for_loop(ExPolicy &&policy, Iter first, Sent last, Args&&... args)

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

Requires:

Iter shall meet the requirements of a forward 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.

  • Iter: The type of the iteration variable (forward iterator).

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for Iter.

  • 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(Iter 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 Rng, typename ...Args>
void for_loop(Rng &&rng, Args&&... args)

The for_loop implements loop functionality over a range specified by a range. 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:

Rng::iterator shall 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
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • 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
  • rng: Refers to theof 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(Rng::iterator 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 Rng, typename ...Args>
util::detail::algorithm_result<ExPolicy>::type for_loop(ExPolicy &&policy, Rng &&rng, Args&&... args)

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

Requires:

Rng::iterator shall meet the requirements of a forward 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

  • rng: Refers to theof 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(Rng::iterator 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 Iter, typename Sent, typename S, typename ...Args>
void for_loop_strided(Iter first, Sent last, S stride, Args&&... args)

The for_loop_strided implements loop functionality over a range specified by iterator bounds. 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_strided without specifying an execution policy is equivalent to specifying hpx::execution::seq as the execution policy.

Requires:

Iter shall 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
  • Iter: The type of the iteration variable (input iterator).

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for Iter.

  • 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 Iter meets the requirements 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(Iter 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 Iter, typename Sent, typename S, typename... Args>util::detail::algorithm_result<ExPolicy>::type hpx::ranges::for_loop_strided(ExPolicy && policy, Iter first, Sent last, S stride Args &&... args)

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

Requires:

Iter shall meet the requirements of a forward 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.

  • Iter: The type of the iteration variable (forward iterator).

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for Iter.

  • 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 Iter meets the requirements 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(Iter 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 Rng, typename S, typename ...Args>
void for_loop_strided(Rng &&rng, S stride, Args&&... args)

The for_loop_strided implements loop functionality over a range specified by a range. 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_strided without specifying an execution policy is equivalent to specifying hpx::execution::seq as the execution policy.

Requires:

Rng::iterator shall 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
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • 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
  • rng: Refers to theof 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 Rng::iterator meets the requirements 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(Rng::iterator 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 Rng, typename S, typename ...Args>
util::detail::algorithm_result<ExPolicy>::type for_loop_strided(ExPolicy &&policy, Rng &&rng, S stride, Args&&... args)

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

Requires:

Rng::iterator shall meet the requirements of a forward 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

  • rng: Refers to theof 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 Rng::iterator meets the requirements 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(Rng::iterator 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.

namespace hpx
namespace ranges

Functions

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

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

The assignments in the parallel

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

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

Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires F to meet the requirements of CopyConstructible.

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

  • rng: Refers to the sequence of elements the algorithm will be applied to.

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

    Ret fun();
    

    The type

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

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 Iter, typename Sent, typename F>
util::detail::algorithm_result<ExPolicy, Iter>::type generate(ExPolicy &&policy, Iter first, Sent last, F &&f)

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

The assignments in the parallel

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

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

Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

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

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

  • F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires F to meet the requirements of CopyConstructible.

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

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

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

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

    Ret fun();
    

    The type

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

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

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type::type includes(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

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

  • Sent1: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

  • Sent2: The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

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

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

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

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.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type::type includes(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements 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

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

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

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

Functions

template<typename ExPolicy, typename Iter, typename Sent, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type is_heap(ExPolicy &&policy, Iter first, Sent last, Comp &&comp = Comp(), Proj &&proj = Proj())

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.

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

  • Sent: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

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

  • sent: 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 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 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 Rng, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type is_heap(ExPolicy &&policy, Rng &&rng, Comp &&comp = Comp(), Proj &&proj = Proj())

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.

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

  • rng: Refers to 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 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 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 Iter, typename Sent, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, Iter>::type is_heap_until(ExPolicy &&policy, Iter first, Sent sent, Comp &&comp = Comp(), Proj &&proj = Proj())

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.

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

  • Sent: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

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

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

template<typename ExPolicy, typename Rng, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type is_heap_until(ExPolicy &&policy, Rng &&rng, Comp &&comp = Comp(), Proj &&proj = Proj())

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.

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

  • rng: Refers to 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 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 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
namespace ranges

Functions

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

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.

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

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.

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

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 Sent, typename Pred = hpx::parallel::v1::detail::less, typename Proj = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, bool>::type is_sorted(ExPolicy &&policy, FwdIter first, Sent last, Pred &&pred = Pred(), Proj &&proj = Proj())

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

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

  • 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 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 Rng, typename Pred = hpx::parallel::v1::detail::less, typename Proj = hpx::parallel::util::projection_identity>
bool is_sorted(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Determines if the range rng 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 = size(rng). S = number of partitions

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.

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

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

Parameters
  • rng: Refers to the sequence of elements 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.

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

Return

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

template<typename ExPolicy, typename Rng, typename Pred = hpx::parallel::v1::detail::less, typename Proj = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, bool>::type is_sorted(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Determines if the range rng 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 = size(rng). 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range 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 is_sorted requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

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

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

  • 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 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 range rng satisfies the predicate passed. If the range rng contains less than two elements, the function always returns true.

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

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.

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

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.

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

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 Sent, typename Pred = hpx::parallel::v1::detail::less, typename Proj = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type is_sorted_until(ExPolicy &&policy, FwdIter first, Sent last, Pred &&pred = Pred(), Proj &&proj = Proj())

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

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

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

template<typename Rng, typename Pred = hpx::parallel::v1::detail::less, typename Proj = hpx::parallel::util::projection_identity>
hpx::traits::range_iterator<Rng>::type is_sorted_until(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Returns the first element in the range rng 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 = size(rng). S = number of partitions

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.

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

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

Parameters
  • rng: Refers to the sequence of elements 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.

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

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 Rng, typename Pred = hpx::parallel::v1::detail::less, typename Proj = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type is_sorted_until(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Returns the first element in the range rng 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 = size(rng). 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range 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 is_sorted_until requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

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

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

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

Functions

template<typename InIter1, typename Sent1, typename InIter2, typename Sent2, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity, typename Pred = detail::less>
bool lexicographical_compare(InIter1 first1, Sent1 last1, InIter2 first2, Sent2 last2, Pred &&pred = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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
  • InIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an input iterator.

  • Sent1: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter1.

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter2.

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

  • Proj1: The type of an optional projection function for FwdIter1. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function for FwdIter2. This defaults to util::projection_identity

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

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

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

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.

template<typename ExPolicy, typename FwdIter1, typename Sent1, typename FwdIter2, typename Sent2, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity, typename Pred = detail::less>
parallel::util::detail::algorithm_result<ExPolicy, bool>::type lexicographical_compare(ExPolicy &&policy, FwdIter1 first1, Sent1 last1, FwdIter2 first2, Sent2 last2, Pred &&pred = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Sent1: The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter1.

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter2.

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

  • Proj1: The type of an optional projection function for FwdIter1. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function for FwdIter2. This defaults to util::projection_identity

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

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

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

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.

template<typename Rng1, typename Rng2, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity, typename Pred = detail::less>
bool lexicographical_compare(Rng1 &&rng1, Rng2 &&rng2, Pred &&pred = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

Checks if the first range rng1 is lexicographically less than the second range rng2. uses a provided predicate to compare elements.

The comparison operations in the parallel

lexicographical_compare algorithm invoked without an execution policy object 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(std::begin(rng1), std::end(rng1)) and N2 = std::distance(std::begin(rng2), std::end(rng2)).

Template Parameters
  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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<>

  • Proj1: The type of an optional projection function for elements of the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function for elements of the second range. This defaults to util::projection_identity

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

  • rng2: Refers to the sequence of elements the algorithm will be applied to.

  • pred: Refers to the comparison function that the first and second ranges will be applied to

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

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

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 bool. The lexicographically_compare algorithm returns true if the first range is lexicographically less, otherwise it returns false. range [first2, last2), it returns false.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity, typename Pred = detail::less>
parallel::util::detail::algorithm_result<ExPolicy, bool>::type lexicographical_compare(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Pred &&pred = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

Checks if the first range rng1 is lexicographically less than the second range rng2. 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(std::begin(rng1), std::end(rng1)) and N2 = std::distance(std::begin(rng2), std::end(rng2)).

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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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<>

  • Proj1: The type of an optional projection function for elements of the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function for elements of the second range. This defaults to util::projection_identity

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

  • rng1: Refers to the sequence of elements the algorithm will be applied to.

  • rng2: Refers to the sequence of elements the algorithm will be applied to.

  • pred: Refers to the comparison function that the first and second ranges will be applied to

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

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

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

Functions

template<typename ExPolicy, typename Rng, typename Comp, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type make_heap(ExPolicy &&policy, Rng &&rng, Comp &&comp, Proj &&proj = Proj{})

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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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
  • rng: Refers to the sequence of elements 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.

  • 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 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<Iter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns Iter otherwise. It returns last.

template<typename ExPolicy, typename Rng, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type make_heap(ExPolicy &&policy, Rng &&rng, Proj &&proj = Proj{})

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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

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

  • 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 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
namespace ranges

Functions

template<typename ExPolicy, typename Iter1, typename Sent, typename Iter2, typename Sent2, typename Iter3, typename Comp = hpx::ranges::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::ranges::merge_result<Iter1, Iter2, Iter3>>::type merge(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Iter3 dest, Comp &&comp = Comp(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Iter1: The type of the source iterators used (deduced) representing the first sequence. This iterator type must meet the requirements of an random access iterator.

  • Sent1: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

  • Iter2: The type of the source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an random access iterator.

  • Sent2: The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

  • Iter3: 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<>

  • Proj1: The type of an optional projection function to be used for elements of the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function to be used for elements of the second range. This defaults to util::projection_identity

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.

  • 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

  • proj1: Specifies the function (or function object) which will be invoked for each of the elements of the first range as a projection operation before the actual comparison comp is invoked.

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second range as a projection operation before the actual comparison comp is invoked.

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<merge_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns merge_result<Iter1, Iter2, Iter3> otherwise. The merge algorithm returns the tuple of the source iterator last1, the source iterator last2, the destination iterator to the end of the dest range.

template<typename ExPolicy, typename Rng1, typename Rng2, typename RandIter3, typename Comp = hpx::ranges::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::ranges::merge_result<typename hpx::traits::range_iterator<Rng1>::type, typename hpx::traits::range_iterator<Rng2>::type, RandIter3>>::type merge(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, RandIter3 dest, Comp &&comp = Comp(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Rng1: The type of the first source range used (deduced). The iterators extracted from this range type must meet the requirements of an random access iterator.

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

  • Proj1: The type of an optional projection function to be used for elements of the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function to be used for elements of the second range. This defaults to util::projection_identity

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

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

  • rng2: Refers to 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

  • proj1: Specifies the function (or function object) which will be invoked for each of the elements of the first range as a projection operation before the actual comparison comp is invoked.

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second range as a projection operation before the actual comparison comp is invoked.

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<merge_result<RandIter1, RandIter2, RandIter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns merge_result<RandIter1, RandIter2, RandIter3> otherwise. The merge algorithm returns the tuple of the source iterator last1, the source iterator last2, the destination iterator to the end of the dest range.

template<typename ExPolicy, typename Iter, typename Sent, typename Comp = hpx::ranges::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, Iter>::type inplace_merge(ExPolicy &&policy, Iter first, Iter middle, Sent last, Comp &&comp = Comp(), Proj &&proj = Proj())

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.

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

  • Sent: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

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

  • 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 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<Iter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns Iter otherwise. The inplace_merge algorithm returns the source iterator last

template<typename ExPolicy, typename Rng, typename RandIter, typename Comp = hpx::ranges::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, RandIter>::type inplace_merge(ExPolicy &&policy, Rng &&rng, RandIter middle, Comp &&comp = Comp(), Proj &&proj = Proj())

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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an random access iterator.

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

  • 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 range of elements 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.

  • 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

  • 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 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<RandIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns RandIter otherwise. The inplace_merge algorithm returns the source iterator last

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename Rng, typename Proj = util::projection_identity, typename F = detail::less>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_type>::type min_element(ExPolicy &&policy, Rng &&rng, 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

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

  • rng: Refers to 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 Rng, typename Proj = util::projection_identity, typename F = detail::less>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_type>::type max_element(ExPolicy &&policy, Rng &&rng, 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

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

  • rng: Refers to 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 Rng, typename Proj = util::projection_identity, typename F = detail::less>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::min(typename hpx::traits::range_traits<Rng>::iterator_type), tag::max(typename hpx::traits::range_traits<Rng>::iterator_type)>>::type minmax_element(ExPolicy &&policy, Rng &&rng, 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

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

  • rng: Refers to 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
namespace ranges

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::mismatch_result<FwdIter1, FwdIter2>>::type mismatch(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

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

  • Sent1: The type of the source iterators used for the end of the first range (deduced).

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

  • Sent2: The type of the source iterators used for the end of the second range (deduced).

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

  • Proj1: The type of an optional projection function applied to the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second range. This defaults to util::projection_identity

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

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

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

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 Rng1, typename Rng2, typename Pred = ranges::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::mimatch_result<FwdIter1, FwdIter2>>::type mismatch(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Rng1: The type of the first source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

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

  • Proj1: The type of an optional projection function applied to the first range. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second range. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements 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

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

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

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 Sent1, typename FwdIter>
util::detail::algorithm_result<ExPolicy, ranges::move_result<FwdIter1, FwdIter>>::type move(ExPolicy &&policy, FwdIter1 iter, Sent1 sent, FwdIter dest)

Moves the elements in the range rng 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 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 std::distance(begin(rng), end(rng)) 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 begin source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

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

  • 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: 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 move algorithm returns a hpx::future<ranges::move_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::move_result<iterator_t<Rng>, 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.

template<typename ExPolicy, typename Rng, typename FwdIter>
util::detail::algorithm_result<ExPolicy, ranges::move_result<typename hpx::traits::range_traits<Rng>::iterator_type, FwdIter>>::type move(ExPolicy &&policy, Rng &&rng, FwdIter dest)

Moves the elements in the range rng 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 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 std::distance(begin(rng), end(rng)) assignments.

Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng: Refers to 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 move algorithm returns a hpx::future<ranges::move_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::move_result<iterator_t<Rng>, 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
namespace parallel

Functions

template<typename ExPolicy, typename Rng, typename Pred, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type partition(ExPolicy &&policy, Rng &&rng, Pred &&pred, Proj &&proj = Proj())

Reorders the elements in the range rng 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: Performs at most 2 * N swaps, exactly N applications of the predicate and projection, where N = std::distance(begin(rng), end(rng)).

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.

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

  • rng: Refers to 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 the range rng. 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 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 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 Rng, typename FwdIter2, typename FwdIter3, typename Pred, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in(typename hpx::traits::range_iterator<Rng>::type), tag::out1(FwdIter2), tag::out2(FwdIter3)>>::type partition_copy(ExPolicy &&policy, Rng &&rng, FwdIter2 dest_true, FwdIter3 dest_false, Pred &&pred, Proj &&proj = Proj())

Copies the elements in the range rng, 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 N assignments, exactly N applications of the predicate pred, where N = std::distance(begin(rng), end(rng)).

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.

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

  • rng: Refers to 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 the range rng. 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
namespace ranges

Functions

template<typename ExPolicy, typename FwdIter, typename Sent, typename T, typename F>
util::detail::algorithm_result<ExPolicy, T>::type reduce(ExPolicy &&policy, FwdIter first, Sent 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 iterator used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Sent: The type of the source sentinel 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 FwdIterB 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 Sent, typename T>
util::detail::algorithm_result<ExPolicy, T>::type reduce(ExPolicy &&policy, FwdIter first, Sent 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 iterator used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Sent: The type of the source sentinel 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, typename Sent>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<FwdIter>::value_type>::type reduce(ExPolicy &&policy, FwdIter first, Sent 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 iterator used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Sent: The type of the source sentinel 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 FwdIterB). 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 FwdIterB.

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 Rng, typename T, typename F>
util::detail::algorithm_result<ExPolicy, T>::type reduce(ExPolicy &&policy, Rng &&rng, 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.

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

  • 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). 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 FwdIterB 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 Rng, typename T>
util::detail::algorithm_result<ExPolicy, T>::type reduce(ExPolicy &&policy, Rng &&rng, 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng: Refers to 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 Rng>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<typename hpx::traits::range_traits<Rng>::iterator_type>::value_type>::type reduce(ExPolicy &&policy, Rng &&rng)

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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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.

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

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 ranges

Functions

template<typename FwdIter, typename Sent, typename T, typename Proj = util::projection_identity>
subrange_t<FwdIter, Sent> remove(FwdIter first, Sent last, T const &value, Proj &&proj = Proj())

Removes all elements that are equal to value from the range [first, last) and and returns a subrange [ret, last), where ret is a past-the-end iterator for the new end of the range.

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==() and the projection proj.

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

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for FwdIter.

  • T: The type of the value to remove (deduced). This value type must meet the requirements of CopyConstructible.

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

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.

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

Return

The remove algorithm returns a subrange_t<FwdIter, Sent>. The remove algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange of the values all in valid but unspecified state.

template<typename ExPolicy, typename FwdIter, typename Sent, typename T, typename Proj = util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<FwdIter, Sent>>::type remove(ExPolicy &&policy, FwdIter first, Sent last, T const &value, Proj &&proj = Proj())

Removes all elements that are equal to value from the range [first, last) and and returns a subrange [ret, last), where ret is a past-the-end iterator for the new end of the range.

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

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for FwdIter.

  • T: The type of the value to remove (deduced). This value type must 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.

  • value: Specifies the value of elements to remove.

  • 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 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<subrange_t<FwdIter, Sent>>. The remove algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange of the values all in valid but unspecified state.

template<typename Rng, typename T, typename Proj = util::projection_identity>
subrange_t<typename hpx::traits::range_iterator<Rng>::type> remove(Rng &&rng, T const &value, Proj &&proj = Proj())

Removes all elements that are equal to value from the range rng and and returns a subrange [ret, util::end(rng)), where ret is a past-the-end iterator for the new end of the range.

The assignments in the parallel

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

Complexity: Performs not more than util::end(rng)

  • util::begin(rng) assignments, exactly util::end(rng) - util::begin(rng) applications of the operator==() and the projection proj.

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.

  • T: The type of the value to remove (deduced). This value type must meet the requirements of CopyConstructible.

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

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

  • value: Specifies the value of elements to remove.

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

Return

The remove algorithm returns a subrange_t<typename hpx::traits::range_iterator<Rng>::type>. The remove algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange of the values all in valid but unspecified state.

template<typename ExPolicy, typename Rng, typename T, typename Proj = util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<typename hpx::traits::range_iterator<Rng>::type>>::type remove(ExPolicy &&policy, Rng &&rng, T const &value, Proj &&proj = Proj())

Removes all elements that are equal to value from the range rng and and returns a subrange [ret, util::end(rng)), where ret is a past-the-end iterator for the new end of the range.

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 util::end(rng)

  • util::begin(rng) assignments, exactly util::end(rng) - util::begin(rng) applications of the operator==() and 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.

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

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

  • value: Specifies the value of elements to remove.

  • 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 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< subrange_t<typename hpx::traits::range_iterator<Rng>::type>> 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 Sent, typename Pred, typename Proj = hpx::parallel::util::projection_identity>
subrange_t<FwdIter, Sent> remove_if(FwdIter first, Sent sent, Pred &&pred, Proj &&proj = Proj())

Removes all elements for which predicate pred returns true from the range [first, last) and returns a subrange [ret, last), where ret is a past-the-end iterator for the new end of the range.

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 and the projection proj.

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

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for FwdIter.

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

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

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.

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

Return

The remove_if algorithm returns a subrange_t<FwdIter, Sent>. The remove_if algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange of the values all in valid but unspecified state.

template<typename ExPolicy, typename FwdIter, typename Sent, typename Pred, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<FwdIter, Sent>>::type remove_if(ExPolicy &&policy, FwdIter first, Sent sent, Pred &&pred, Proj &&proj = Proj())

Removes all elements for which predicate pred returns true from the range [first, last) and returns a subrange [ret, last), where ret is a past-the-end iterator for the new end of the range.

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

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for FwdIter.

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

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

  • 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_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<subrange_t<FwdIter, Sent>>. The remove_if algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange of the values all in valid but unspecified state.

template<typename Rng, typename T, typename Proj = util::projection_identity>
subrange_t<typename hpx::traits::range_iterator<Rng>::type> remove_if(Rng &&rng, Pred &&pred, Proj &&proj = Proj())

Removes all elements that are equal to value from the range rng and and returns a subrange [ret, util::end(rng)), where ret is a past-the-end iterator for the new end of the range.

The assignments in the parallel

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

Complexity: Performs not more than util::end(rng)

  • util::begin(rng) assignments, exactly util::end(rng) - util::begin(rng) applications of the operator==() and the projection proj.

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.

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

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

Parameters
  • rng: Refers to 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.

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

Return

The remove_if algorithm returns a subrange_t<typename hpx::traits::range_iterator<Rng>::type>. The remove_if algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange of the values all in valid but unspecified state.

template<typename ExPolicy, typename Rng, typename Pred, typename Proj = util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<typename hpx::traits::range_iterator<Rng>::type>>::type remove_if(ExPolicy &&policy, Rng &&rng, Pred &&pred, Proj &&proj = Proj())

Removes all elements that are equal to value from the range rng and and returns a subrange [ret, util::end(rng)), where ret is a past-the-end iterator for the new end of the range.

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 util::end(rng)

  • util::begin(rng) assignments, exactly util::end(rng) - util::begin(rng) applications of the operator==() and 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.

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

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

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

  • 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_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<subrange_t< typename hpx::traits::range_iterator<Rng>::type>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The remove_if algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange of the values all in valid but unspecified state.

namespace hpx
namespace ranges

Functions

template<typename Iter, typename Sent, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
Iter replace(Iter first, Sent sent, 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, *i) == old_value

Note

Complexity: Performs exactly last - first assignments.

The assignments in the parallel

replace algorithm execute in sequential order in the calling thread.
Template Parameters
  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of an input iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

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

Return

The replace algorithm returns an Iter.

template<typename Rng, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
hpx::traits::range_iterator<Rng>::type replace(Rng &&rng, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria with new_value in the range rng.

Effects: Substitutes elements referred by the iterator it in the range rng with new_value, when the following corresponding conditions hold: INVOKE(proj, *i) == old_value

Note

Complexity: Performs exactly util::end(rng) - util::begin(rng) assignments.

The assignments in the parallel

replace algorithm execute in sequential order in the calling thread.
Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range 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
  • rng: Refers to 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.

Return

The replace algorithm returns an hpx::traits::range_iterator<Rng>::type.

template<typename ExPolicy, typename Iter, typename Sent, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, Iter>::type replace(ExPolicy &&policy, Iter first, Sent sent, 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, *i) == old_value

Note

Complexity: Performs exactly last - first assignments.

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.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of a forward iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

  • 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<Iter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns Iter otherwise.

template<typename ExPolicy, typename Rng, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type replace(ExPolicy &&policy, Rng &&rng, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria with new_value in the range rng.

Effects: Substitutes elements referred by the iterator it in the range rng with new_value, when the following corresponding conditions hold: INVOKE(proj, *i) == old_value

Note

Complexity: Performs exactly util::end(rng) - util::begin(rng) assignments.

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

  • rng: Refers to 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 sequenced_policy execute in sequential order in the calling thread.

Return

The replace algorithm returns an hpx::future<hpx::traits::range_iterator<Rng>::type> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns hpx::traits::range_iterator<Rng>::type otherwise.

template<typename Iter, typename Sent, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>
Iter replace_if(Iter first, Sent sent, Pred &&pred, 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, sent).

Effects: Substitutes elements referred by the iterator it in the range [first, sent) with new_value, when the following corresponding conditions hold: INVOKE(f, INVOKE(proj, *it)) != false

Note

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

The assignments in the parallel

replace_if algorithm 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 executes the assignments.

  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of a forward iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

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

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

Return

The replace_if algorithm returns an Iter It returns last.

template<typename Rng, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>
hpx::traits::range_iterator<Rng>::type replace_if(Rng &&rng, Pred &&pred, T const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria (for which predicate pred returns true) with new_value in the range rng.

Effects: Substitutes elements referred by the iterator it in the range rng with new_value, when the following corresponding conditions hold: INVOKE(f, INVOKE(proj, *it)) != false

Note

Complexity: Performs exactly util::end(rng) - util::begin(rng) applications of the predicate.

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.
Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a forward iterator.

  • Pred: 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
  • rng: Refers to 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 rng.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 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 an hpx::traits::range_iterator<Rng>::type It returns last.

template<typename ExPolicy, typename Iter, typename Sent, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>parallel::util::detail::algorithm_result<ExPolicy, Iter>::type t hpx::ranges::replace_if(ExPolicy && policy, Iter first, Sent sent, Pred && pred, T const & new_value, Proj && proj = Proj())

Replaces all elements satisfying specific criteria (for which predicate pred returns true) with new_value in the range rng.

Effects: Substitutes elements referred by the iterator it in the range rng with new_value, when the following corresponding conditions hold: INVOKE(f, INVOKE(proj, *it)) != false

Note

Complexity: Performs exactly util::end(rng) - util::begin(rng) applications of the predicate.

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.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of a forward iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

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

  • 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 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<Iter> if the execution policy is of type sequenced_task_policy or parallel_task_policy. It returns last.

template<typename ExPolicy, typename Rng, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type replace_if(ExPolicy &&policy, Rng &&rng, Pred &&pred, T const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria (for which predicate pred returns true) with new_value in the range rng.

Effects: Substitutes elements referred by the iterator it in the range rng with new_value, when the following corresponding conditions hold: INVOKE(f, INVOKE(proj, *it)) != false

Note

Complexity: Performs exactly util::end(rng) - util::begin(rng) applications of the predicate.

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.
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 a forward iterator.

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

  • rng: Refers to 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 rng.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 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<typename hpx::traits::range_iterator<Rng>::type> if the execution policy is of type sequenced_task_policy or parallel_task_policy. It returns last.

template<typename Initer, typename Sent, typename OutIter, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
replace_copy_result<InIter, OutIter> replace_copy(InIter first, Sent sent, OutIter dest, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, sent) 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 + (sent - 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 execute in sequential order in the calling thread.
Note

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

Template Parameters
  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of an input iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

  • OutIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output 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
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.

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

Return

The replace_copy algorithm returns an in_out_result<InIter, OutIter>. 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 Rng, typename OutIter, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
replace_copy_result<typename hpx::traits::range_iterator<Rng>::type, OutIter> replace_copy(Rng &&rng, OutIter dest, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Copies the all elements from the range rbg 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 + (util::end(rng) - util::begin(rng))) 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 execute in sequential order in the calling thread.
Note

Complexity: Performs exactly util::end(rng) - util::begin(rng) applications of the predicate.

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • OutIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output 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
  • rng: Refers to 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.

Return

The replace_copy algorithm returns an in_out_result<typename hpx::traits::range_iterator< Rng>::type, OutIter>. 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 Sent, typename FwdIter2, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, replace_copy_result<FwdIter1, FwdIter2>>::type replace_copy(ExPolicy &&policy, FwdIter1 first, Sent sent, FwdIter2 dest, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, sent) 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 + (sent - 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 sent - 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 iterator used (deduced). The iterator type must meet the requirements of an forward iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

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

  • sent: 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<in_out_result<FwdIter1, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns in_out_result<FwdIter1, FwdIter2> otherwise. The copy algorithm returns the pair of the forward iterator last and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename Rng, typename FwdIter, typename T1, typename T2, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, replace_copy_result<typename hpx::traits::range_iterator<Rng>::type, FwdIter>>::type replace_copy(ExPolicy &&policy, Rng &&rng, FwdIter dest, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Copies the all elements from the range rbg 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 + (util::end(rng) - util::begin(rng))) 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 util::end(rng) - util::begin(rng) 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

  • rng: Refers to 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<in_out_result< typename hpx::traits::range_iterator<Rng>::type, FwdIter>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns in_out_result< typename hpx::traits::range_iterator<Rng>::type, FwdIter>> The copy algorithm returns the pair of the input iterator last and the forward iterator to the element in the destination range, one past the last element copied.

template<typename InIter, typename Sent, typename OutIter, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>
replace_copy_if_result<InIter, OutIter> replace_copy_if(InIter first, Sent sent, OutIter dest, Pred &&pred, T const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, sent) 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 + (sent - 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 execute in sequential order in the calling thread.
Note

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

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

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for InIter.

  • OutIter: 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 the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires Pred 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
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.

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

Return

The replace_copy_if algorithm returns a in_out_result<InIter, OutIter>. 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.

template<typename Rng, typename OutIter, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>
replace_copy_if_result<typename hpx::traits::range_iterator<Rng>::type, OutIter> replace_copy_if(Rng &&rng, OutIter dest, Pred &&pred, T const &new_value, Proj &&proj = Proj())

Copies the all elements from the range rng 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 + (util::end(rng) - util::begin(rng))) 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 execute in sequential order in the calling thread.
Note

Complexity: Performs exactly util::end(rng) - util::begin(rng) applications of the predicate.

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • OutIter: 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 the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires Pred 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
  • rng: Refers to 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 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.

Return

The replace_copy_if algorithm returns an in_out_result<typename hpx::traits::range_iterator<Rng>::type, OutIter>. 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.

template<typename ExPolicy, typename FwdIter1, typename Sent, typename FwdIter2, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, replace_copy_if_result<FwdIter1, FwdIter2>>::type replace_copy_if(ExPolicy &&policy, FwdIter1 first, Sent sent, FwdIter2 dest, Pred &&pred, T const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, sent) 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 + (sent - 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 sent - 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 iterator used (deduced). The iterator type must meet the requirements of a forward iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for InIter.

  • 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 equal requires Pred 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.

  • sent: 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 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_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 an hpx::future<FwdIter1, FwdIter2>. 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.

template<typename ExPolicy, typename Rng, typename FwdIter, typename Pred, typename T, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, replace_copy_if_result<typename hpx::traits::range_iterator<Rng>::type, FwdIter>>::type replace_copy_if(ExPolicy &&policy, Rng &&rng, FwdIter dest, Pred &&pred, T const &new_value, Proj &&proj = Proj())

Copies the all elements from the range rng 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 + (util::end(rng) - util::begin(rng))) 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 util::end(rng) - util::begin(rng) 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

  • rng: Refers to 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 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_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 an hpx::future<in_out_result<typename hpx::traits::range_iterator<Rng>::type, OutIter>>. 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 ranges

Functions

template<typename Iter, typename Sent>
Iter reverse(Iter first, Sent 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 execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last.

Template Parameters
  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of an input iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

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.

Return

The reverse algorithm returns a Iter. It returns last.

template<typename Rng>
hpx::traits::range_iterator<Rng>::type reverse(Rng &&rng)

Uses rng as the source range, as if using util::begin(rng) as first and ranges::end(rng) as 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 execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last.

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a bidirectional iterator.

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

Return

The reverse algorithm returns a hpx::traits::range_iterator<Rng>::type. It returns last.

template<typename ExPolicy, typename Iter, typename Sent>
parallel::util::detail::algorithm_result<ExPolicy, Iter>::type reverse(ExPolicy &&policy, Iter first, Sent 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.

  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of an input iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

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<Iter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns Iter otherwise. It returns last.

template<typename ExPolicy, typename Rng>
parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type reverse(ExPolicy &&policy, Rng &&rng)

Uses rng as the source range, as if using util::begin(rng) as first and ranges::end(rng) as 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a bidirectional iterator.

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.

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<typename hpx::traits::range_iterator<Rng>::type> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns hpx::future< typename hpx::traits::range_iterator<Rng>::type> otherwise. It returns last.

template<typename Iter, typename Sent, typename OutIter>
reverse_copy_result<Iter, OutIter> reverse_copy(Iter first, Sent last, OutIter result)

Copies the elements from the range [first, last) to another range beginning at result in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(result + (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 [result, result+(last-first)) respectively) overlap, the behavior is undefined.

The assignments in the parallel

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

Complexity: Performs exactly last - first assignments.

Template Parameters
  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of an input iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

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

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.

  • result: Refers to the begin of the destination range.

Return

The reverse_copy algorithm returns a reverse_copy_result<Iter, OutIter>. The reverse_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 Rng, typename OutIter>
ranges::reverse_copy_result<typename hpx::traits::range_iterator<Rng>::type, OutIter> reverse_copy(Rng &&rng, OutIter result)

Uses rng as the source range, as if using util::begin(rng) as first and ranges::end(rng) as last. Copies the elements from the range [first, last) to another range beginning at result in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(result + (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 [result, result+(last-first)) respectively) overlap, the behavior is undefined.

The assignments in the parallel

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

Complexity: Performs exactly last - first assignments.

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a bidirectional iterator.

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

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

  • result: Refers to the begin of the destination range.

Return

The reverse_copy algorithm returns a ranges::reverse_copy_result< typename hpx::traits::range_iterator<Rng>::type, OutIter>>::type. The reverse_copy algorithm returns an object equal to {last, result + N} where N = last - first

template<typename ExPolicy, typename Iter, typename Sent, typename OutIter>
parallel::util::detail::algorithm_result<ExPolicy, reverse_copy_result<Iter, OutIter>>::type reverse_copy(ExPolicy &&policy, Iter first, Sent last, OutIter result)

Copies the elements from the range [first, last) to another range beginning at result in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(result + (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 [result, result+(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.

  • Iter: The type of the source iterator used (deduced). The iterator type must meet the requirements of an input iterator.

  • Sent: The type of the end iterators used (deduced). This sentinel type must be a sentinel for Iter.

  • OutIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output 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.

  • result: 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<reverse_copy_result<Iter, OutIter> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns reverse_copy_result<Iter, OutIter> otherwise. The reverse_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 Rng, typename OutIter>
util::detail::algorithm_result<ExPolicy, ranges::reverse_copy_result<typename hpx::traits::range_iterator<Rng>::type, OutIter>>::type reverse_copy(ExPolicy &&policy, Rng &&rng, OutIter result)

Uses rng as the source range, as if using util::begin(rng) as first and ranges::end(rng) as last. Copies the elements from the range [first, last) to another range beginning at result in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(result + (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 [result, result+(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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a bidirectional iterator.

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

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.

  • result: 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<ranges::reverse_copy_result< typename hpx::traits::range_iterator<Rng>::type, OutIter>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::reverse_copy_result< typename hpx::traits::range_iterator<Rng>::type, OutIter> otherwise. The reverse_copy algorithm returns an object equal to {last, result + N} where N = last - first

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename Rng>
util::detail::algorithm_result<ExPolicy, util::in_out_result<typename hpx::traits::range_iterator<Rng>::type, typename hpx::traits::range_iterator<Rng>::type>>::type rotate(ExPolicy &&policy, Rng &&rng, typename hpx::traits::range_iterator<Rng>::type middle)

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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a forward iterator.

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.

  • middle: Refers to the element that should appear at the beginning of the rotated range.

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 Rng, typename OutIter>
util::detail::algorithm_result<ExPolicy, util::in_out_result<typename hpx::traits::range_iterator<Rng>::type, OutIter>>::type rotate_copy(ExPolicy &&policy, Rng &&rng, typename hpx::traits::range_iterator<Rng>::type middle, OutIter 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a forward iterator.

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

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.

  • middle: Refers to the element that should appear at the beginning of the rotated range.

  • 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(FwdIter), tag::out(OutIter)> > if the execution policy is of type parallel_task_policy and returns tagged_pair<tag::in(FwdIter), tag::out(OutIter)> otherwise. The rotate_copy algorithm returns the output iterator to the element past the last element copied.

namespace hpx
namespace ranges

Functions

template<typename FwdIter, typename Sent, typename FwdIter2, typename Sent2, typename Pred = hpx::ranges::equal_to, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
FwdIter search(FwdIter first, Sent last, FwdIter2 s_first, Sent2 s_last, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

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

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

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

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

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

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

  • 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 actual predicate 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 actual predicate is invoked.

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 Sent, typename FwdIter2, typename Sent2, typename Pred = hpx::ranges::equal_to, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type search(ExPolicy &&policy, FwdIter first, Sent last, FwdIter2 s_first, Sent2 s_last, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

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

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

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

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

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

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

  • 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 actual predicate 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 actual predicate is invoked.

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 Rng1, typename Rng2, typename Pred = hpx::ranges::equal_to, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity>
hpx::traits::range_iterator<Rng1>::type search(Rng1 &&rng1, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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
  • Rng1: The type of the examine range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the search range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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<>

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

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

Parameters
  • rng1: Refers to the sequence of elements the algorithm will be examining.

  • rng2: Refers to the sequence of elements 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

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

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

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 Rng1, typename Rng2, typename Pred = hpx::ranges::equal_to, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng1>::type>::type search(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Rng1: The type of the examine range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the search range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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<>

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

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

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

  • rng1: Refers to the sequence of elements the algorithm will be examining.

  • rng2: Refers to the sequence of elements 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

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

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

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 Sent2, typename Pred = hpx::ranges::equal_to, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
FwdIter search_n(ExPolicy &&policy, FwdIter first, std::size_t count, FwdIter2 s_first, Sent s_last, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

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

  • 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

  • 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 actual predicate 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 actual predicate is invoked.

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 Sent2, typename Pred = hpx::ranges::equal_to, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type search_n(ExPolicy &&policy, FwdIter first, std::size_t count, FwdIter2 s_first, Sent2 s_last, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

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

  • 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

  • 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 actual predicate 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 actual predicate is invoked.

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.

template<typename Rng1, typename Rng2, typename Pred = hpx::ranges::equal_to, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity>
hpx::traits::range_iterator<Rng1>::type search_n(Rng1 &&rng1, std::size_t count, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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
  • Rng1: The type of the examine range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the search range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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<>

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

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

Parameters
  • rng1: Refers to the sequence of elements the algorithm will be examining.

  • count: The number of elements to apply the algorithm on.

  • rng2: Refers to the sequence of elements 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

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

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

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 Rng1, typename Rng2, typename Pred = hpx::ranges::equal_to, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng1>::type>::type search_n(ExPolicy &&policy, Rng1 &&rng1, std::size_t count, Rng2 &&rng2, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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.

  • Rng1: The type of the examine range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the search range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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<>

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

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

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

  • rng1: Refers to the sequence of elements the algorithm will be examining.

  • count: The number of elements to apply the algorithm on.

  • rng2: Refers to the sequence of elements 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

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

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

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.

namespace hpx
namespace ranges

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_difference_result<Iter1, Iter3>>::type set_difference(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

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

  • Sent1: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

  • Sent2: The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

  • Iter3: 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<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_difference algorithm returns a hpx::future<ranges::set_difference_result<Iter1, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_difference_result<Iter1, Iter3> otherwise. The set_difference algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_difference_result<typename traits::range_iterator<Rng1>::type, Iter3>>::type set_difference(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter3: 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<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements 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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_difference algorithm returns a hpx::future<ranges::set_difference_result<Iter1, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_difference_result<Iter1, Iter3> otherwise. where Iter1 is range_iterator_t<Rng1> and Iter2 is range_iterator_t<Rng2> The set_difference algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace ranges

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_intersection_result<Iter1, Iter2, Iter3>>::type set_intersection(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

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

  • Sent1: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

  • Sent2: The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

  • Iter3: 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<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_intersection algorithm returns a hpx::future<ranges::set_intersection_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_intersection_result<Iter1, Iter2, Iter3> otherwise. The set_intersection algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_intersection_result<typename traits::range_iterator<Rng1>::type, typename traits::range_iterator<Rng2>::type, Iter3>>::type set_intersection(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter3: 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<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements 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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_intersection algorithm returns a hpx::future<ranges::set_intersection_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_intersection_result<Iter1, Iter2, Iter3> otherwise. where Iter1 is range_iterator_t<Rng1> and Iter2 is range_iterator_t<Rng2> The set_intersection algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace ranges

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_symmetric_difference_result<Iter1, Iter2, Iter3>>::type set_symmetric_difference(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

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

  • Sent1: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

  • Sent2: The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

  • Iter3: 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<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_symmetric_difference algorithm returns a hpx::future<ranges::set_symmetric_difference_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_symmetric_difference_result<Iter1, Iter2, Iter3> otherwise. The set_symmetric_difference algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_symmetric_difference_result<typename traits::range_iterator<Rng1>::type, typename traits::range_iterator<Rng2>::type, Iter3>>::type set_symmetric_difference(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter3: 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<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements 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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_symmetric_difference algorithm returns a hpx::future<ranges::set_symmetric_difference_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_symmetric_difference_result<Iter1, Iter2, Iter3> otherwise. where Iter1 is range_iterator_t<Rng1> and Iter2 is range_iterator_t<Rng2> The set_symmetric_difference algorithm returns the output iterator to the element in the destination range, one past the last element copied.

namespace hpx
namespace ranges

Functions

template<typename ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_union_result<Iter1, Iter2, Iter3>>::type set_union(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

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

  • Sent1: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.

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

  • Sent2: The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

  • Iter3: 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_union requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_union algorithm returns a hpx::future<ranges::set_union_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_union_result<Iter1, Iter2, Iter3> otherwise. The set_union algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Iter3, typename Pred = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::set_union_result<typename traits::range_iterator<Rng1>::type, typename traits::range_iterator<Rng2>::type, Iter3>>::type set_union(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 (

sequenced_policy) or in a single new thread spawned from the current thread (for sequenced_task_policy).
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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter3: 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_union requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>

  • Proj1: The type of an optional projection function applied to the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function applied to the second sequence. This defaults to util::projection_identity

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

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

  • rng2: Refers to the second sequence of elements 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

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

  • proj2: Specifies the function (or function object) which will be invoked for each of the elements of the second sequence as a projection operation before the actual predicate op 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 set_union algorithm returns a hpx::future<ranges::set_union_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_union_result<Iter1, Iter2, Iter3> otherwise. where Iter1 is range_iterator_t<Rng1> and Iter2 is range_iterator_t<Rng2> 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 Rng, typename Compare = v1::detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type sort(ExPolicy &&policy, Rng &&rng, Compare &&comp = Compare(), Proj &&proj = Proj())

Sorts the elements in the range rng 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(begin(rng), end(rng)) 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng: Refers to 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<Iter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns Iter otherwise. It returns last.

namespace hpx
namespace parallel

Functions

template<typename ExPolicy, typename Rng, typename Compare = v1::detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type stable_sort(ExPolicy &&policy, Rng &&rng, 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng: Refers to 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 ranges

Functions

template<typename ExPolicy, typename Rng, typename OutIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, ranges::unary_transform_result<typename hpx::traits::range_iterator<Rng>::type, OutIter>>::type transform(ExPolicy &&policy, Rng &&rng, OutIter dest, F &&f, Proj &&proj = Proj())

Applies the given function f to the given range rng 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 size(rng) 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • OutIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output 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.

  • rng: Refers to 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 range_iterator<Rng>::type can be dereferenced and then implicitly converted to Type. The type Ret must be such that an object of type OutIter can be dereferenced and assigned a value of type Ret.

  • 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 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<ranges::unary_transform_result<range_iterator<Rng>::type, OutIter> > if the execution policy is of type parallel_task_policy and returns ranges::unary_transform_result<range_iterator<Rng>::type, OutIter> 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 Sent1, typename FwdIter2, typename F, typename Proj = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, ranges::unary_transform_result<FwdIter1, FwdIter2>>::type transform(ExPolicy &&policy, FwdIter1 first, Sent1 last, FwdIter2 dest, F &&f, Proj &&proj = Proj())

Applies the given function f to the given range rng 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 size(rng) 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.

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

  • FwdIter2: The type of the source iterators for the first range 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 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 first 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.

  • 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 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<ranges::unary_transform_result<FwdIter1, FwdIter2> > if the execution policy is of type parallel_task_policy and returns ranges::unary_transform_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 Sent1, typename FwdIter2, typename Sent2, typename FwdIter3, typename F, typename Proj1 = hpx::parallel::util::projection_identity, typename Proj2 = hpx::parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, ranges::binary_transform_result<FwdIter1, FwdIter2, FwdIter3>>::type transform(ExPolicy &&policy, FwdIter1 first1, Sent1 last1, FwdIter2 first2, Sent2 last2, FwdIter3 dest, F &&f, Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

Applies the given function f to pairs of elements from two ranges: one defined by rng 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 size(rng) 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.

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

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

  • Sent2: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for FwdIter2.

  • FwdIter3: The type of the source iterators for the first range 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 transform requires F to meet the requirements of CopyConstructible.

  • Proj1: The type of an optional projection function to be used for elements of the first sequence. This defaults to util::projection_identity

  • Proj2: The type of an optional projection function to be used for elements of the second sequence. This defaults to util::projection_identity

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.

  • last2: Refers to the end 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.

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

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

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<ranges::binary_transform_result<FwdIter1, FwdIter2, FwdIter3> > if the execution policy is of type parallel_task_policy and returns ranges::binary_transform_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

Functions

template<typename ExPolicy, typename Rng, typename T, typename Reduce, typename Convert>
util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Rng &&rng, 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.

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

  • rng: Refers to the sequence of elements the algorithm will be applied to.

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

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

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 Rng1, typename FwdIter2, typename T>
util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Rng1 &&rng1, 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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng1: Refers to the 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 Rng1, typename FwdIter2, typename T, typename Reduce, typename Convert>
util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Rng1 &&rng1, 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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.

  • rng1: Refers to the 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 ranges

Functions

template<typename InIter, typename Sent1, typename FwdIter, typename Sent2>
hpx::parallel::util::in_out_result<InIter, FwdIter> uninitialized_copy(InIter first1, Sent1 last1, FwdIter first2, Sent2 last2)

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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

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

  • Sent1: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter2.

Parameters
  • first1: Refers to the beginning of the sequence of elements that will be copied from

  • last1: Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied

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

  • last2: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

Return

The uninitialized_copy algorithm returns an in_out_result<InIter, FwdIter>. The uninitialized_copy algorithm returns an input iterator to one past the last element copied from and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename FwdIter1, typename Sent1, typename FwdIter2, typename Sent2>
parallel::util::detail::algorithm_result<ExPolicy, parallel::util::in_out_result<FwdIter1, FwdIter2>>::type uninitialized_copy(ExPolicy &&policy, FwdIter1 first1, Sent1 last1, FwdIter2 first2, Sent2 last2)

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

  • Sent1: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter2.

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

  • first1: Refers to the beginning of the sequence of elements that will be copied from

  • last1: Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

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

  • last2: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

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<in_out_result<InIter, FwdIter>>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns in_out_result<InIter, FwdIter> otherwise. The uninitialized_copy algorithm returns an input iterator to one past the last element copied from and the output iterator to the element in the destination range, one past the last element copied.

template<typename Rng1, typename Rng2>
hpx::parallel::util::in_out_result<typename hpx::traits::range_traits<Rng1>::iterator_type, typename hpx::traits::range_traits<Rng2>::iterator_type> uninitialized_copy(Rng1 &&rng1, Rng2 &&rng2)

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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

Template Parameters
  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the destination range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

Parameters
  • rng1: Refers to the range from which the elements will be copied from

  • rng2: Refers to the range to which the elements will be copied to

Return

The uninitialized_copy algorithm returns an in_out_result<typename hpx::traits::range_traits<Rng1> ::iterator_type, typename hpx::traits::range_traits<Rng2> ::iterator_type>. The uninitialized_copy algorithm returns an input iterator to one past the last element copied from and the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename Rng1, typename Rng2>
parallel::util::detail::algorithm_result<ExPolicy, hpx::parallel::util::in_out_result<typename hpx::traits::range_traits<Rng1>::iterator_type, typename hpx::traits::range_traits<Rng2>::iterator_type>>::type uninitialized_copy(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2)

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.

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the destination range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

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

  • rng1: Refers to the range from which the elements will be copied from

  • rng2: Refers to the range to which the elements will be copied to

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<in_out_result<InIter, FwdIter>>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns in_out_result< typename hpx::traits::range_traits<Rng1>::iterator_type , typename hpx::traits::range_traits<Rng2>::iterator_type> otherwise. The uninitialized_copy algorithm returns the input iterator to one past the last element copied from and the output iterator to the element in the destination range, one past the last element copied.

template<typename InIter, typename Size, typename FwdIter, typename Sent2>
hpx::parallel::util::in_out_result<InIter, FwdIter> uninitialized_copy_n(InIter first1, Size count, FwdIter first2, Sent2 last2)

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 last - first assignments.

Template Parameters
  • InIter: 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.

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

Parameters
  • first1: Refers to the beginning of the sequence of elements that will be copied from

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

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

  • last2: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

Return

The uninitialized_copy_n algorithm returns in_out_result<InIter, FwdIter>. The uninitialized_copy_n 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, typename Sent2>
parallel::util::detail::algorithm_result<ExPolicy, parallel::util::in_out_result<FwdIter1, FwdIter2>>::type uninitialized_copy_n(ExPolicy &&policy, FwdIter1 first1, Size count, FwdIter2 first2, Sent2 last2)

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter2.

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

  • first1: Refers to the beginning of the sequence of elements that will be copied from

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

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

  • last1: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

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<in_out_result<FwdIter1, 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 ranges

Functions

template<typename FwdIter, typename Sent>
FwdIter uninitialized_default_construct(FwdIter first, Sent last)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range 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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

Template Parameters
  • FwdIter: The type of the source iterators used (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 FwdIter.

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

  • last: Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

Return

The uninitialized_default_construct algorithm returns a returns FwdIter. The uninitialized_default_construct algorithm returns the output iterator to the element in the range, one past the last element constructed.

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

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range 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.

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

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 sentinel value denoting the end of the sequence of elements the algorithm will be applied.

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<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The uninitialized_default_construct algorithm returns the iterator to the element in the source range, one past the last element constructed.

template<typename Rng>
hpx::traits::range_traits<Rng>::iterator_type uninitialized_default_construct(Rng &&rng)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range 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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

Parameters
  • rng: Refers to the range to which will be default constructed.

Return

The uninitialized_default_construct algorithm returns a returns hpx::traits::range_traits<Rng> ::iterator_type. The uninitialized_default_construct algorithm returns the output iterator to the element in the range, one past the last element constructed.

template<typename ExPolicy, typename Rng>
parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_type>::type uninitialized_default_construct(ExPolicy &&policy, Rng &&rng)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

  • rng: Refers to the range to which the value will be default consutrcted

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<typename hpx::traits::range_traits<Rng> ::iterator_type>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns typename hpx::traits::range_traits<Rng>::iterator_type otherwise. The uninitialized_default_construct algorithm returns the output iterator to the element in the range, one past the last element constructed.

template<typename FwdIter, typename Size>
FwdIter uninitialized_default_construct_n(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 without an execution policy object execute in sequential order in the calling thread.
Note

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

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

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

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.

Return

The uninitialized_default_construct_n algorithm returns a returns FwdIter. The uninitialized_default_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

template<typename ExPolicy, typename FwdIter, typename Size>
parallel::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 ranges

Functions

template<typename FwdIter, typename Sent, typename T>
FwdIter uninitialized_fill(FwdIter first, Sent 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 assignments in the ranges

uninitialized_fill algorithm invoked without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last

Template Parameters
  • FwdIter: The type of the source iterators used (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 FwdIter.

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

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

  • last: Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • value: The value to be assigned.

Return

The uninitialized_fill algorithm returns a returns FwdIter. The uninitialized_fill algorithm returns the output iterator to the element in the range, one past the last element copied.

template<typename ExPolicy, typename FwdIter, typename Sent>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type uninitialized_fill(ExPolicy &&policy, FwdIter first, Sent 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 assignments 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.

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

  • 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 sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • value: The value to be assigned.

The assignments 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 returns FwdIter. The uninitialized_fill algorithm returns the output iterator to the element in the range, one past the last element copied.

template<typename Rng, typename T>
hpx::traits::range_traits<Rng>::iterator_type uninitialized_fill(Rng &&rng, 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 assignments in the parallel

uninitialized_fill algorithm invoked without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Linear in the distance between first and last

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

Parameters
  • rng: Refers to the range to which the value will be filled

  • value: The value to be assigned.

Return

The uninitialized_fill algorithm returns a returns hpx::traits::range_traits<Rng> ::iterator_type. The uninitialized_fill algorithm returns the output iterator to the element in the range, one past the last element copied.

template<typename ExPolicy, typename Rng, typename T>
parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng1>::iterator_type>::type uninitialized_fill(ExPolicy &&policy, Rng &&rng, 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 assignments 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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

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

  • rng: Refers to the range to which the value will be filled

  • value: The value to be assigned.

The assignments 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<typename hpx::traits::range_traits<Rng> ::iterator_type>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns typename hpx::traits::range_traits<Rng>::iterator_type otherwise. The uninitialized_fill algorithm returns the iterator to one past the last element filled in the range.

template<typename FwdIter, typename Size, typename T>
FwdIter uninitialized_fill_n(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 assignments 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
  • 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
  • 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.

Return

The uninitialized_fill_n algorithm returns a returns FwdIter. The uninitialized_fill_n algorithm returns the output iterator to the element in the range, one past the last element copied.

template<typename ExPolicy, typename FwdIter, typename Size, typename T>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::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 assignments 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 assignments 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<FwdIter>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The uninitialized_fill_n algorithm returns the output iterator to the element in the range, one past the last element copied.

namespace hpx
namespace ranges

Functions

template<typename InIter, typename Sent1, typename FwdIter, typename Sent2>
hpx::parallel::util::in_out_result<InIter, FwdIter> uninitialized_move(InIter first1, Sent1 last1, FwdIter first2, Sent2 last2)

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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

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

  • Sent1: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter2.

Parameters
  • first1: Refers to the beginning of the sequence of elements that will be moved from

  • last1: Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied

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

  • last2: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

Return

The uninitialized_move algorithm returns an in_out_result<InIter, FwdIter>. The uninitialized_move algorithm returns an input iterator to one past the last element moved from and the output iterator to the element in the destination range, one past the last element moved.

template<typename ExPolicy, typename FwdIter1, typename Sent1, typename FwdIter2, typename Sent2>
parallel::util::detail::algorithm_result<ExPolicy, parallel::util::in_out_result<FwdIter1, FwdIter2>>::type uninitialized_move(ExPolicy &&policy, FwdIter1 first1, Sent1 last1, FwdIter2 first2, Sent2 last2)

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

  • Sent1: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter2.

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

  • first1: Refers to the beginning of the sequence of elements that will be moved from

  • last1: Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

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

  • last2: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

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<in_out_result<InIter, FwdIter>>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns in_out_result<InIter, FwdIter> otherwise. The uninitialized_move algorithm returns an input iterator to one past the last element moved from and the output iterator to the element in the destination range, one past the last element moved.

template<typename Rng1, typename Rng2>
hpx::parallel::util::in_out_result<typename hpx::traits::range_traits<Rng1>::iterator_type, typename hpx::traits::range_traits<Rng2>::iterator_type> uninitialized_move(Rng1 &&rng1, Rng2 &&rng2)

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 without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

Template Parameters
  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the destination range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

Parameters
  • rng1: Refers to the range from which the elements will be moved from

  • rng2: Refers to the range to which the elements will be moved to

Return

The uninitialized_move algorithm returns an in_out_result<typename hpx::traits::range_traits<Rng1> ::iterator_type, typename hpx::traits::range_traits<Rng2> ::iterator_type>. The uninitialized_move algorithm returns an input iterator to one past the last element moved from and the output iterator to the element in the destination range, one past the last element moved.

template<typename ExPolicy, typename Rng1, typename Rng2>
parallel::util::detail::algorithm_result<ExPolicy, hpx::parallel::util::in_out_result<typename hpx::traits::range_traits<Rng1>::iterator_type, typename hpx::traits::range_traits<Rng2>::iterator_type>>::type uninitialized_move(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2)

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

  • Rng1: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2: The type of the destination range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

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

  • rng1: Refers to the range from which the elements will be moved from

  • rng2: Refers to the range to which the elements will be moved to

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<in_out_result<InIter, FwdIter>>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns in_out_result< typename hpx::traits::range_traits<Rng1>::iterator_type , typename hpx::traits::range_traits<Rng2>::iterator_type> otherwise. The uninitialized_move algorithm returns the input iterator to one past the last element moved from and the output iterator to the element in the destination range, one past the last element moved.

template<typename InIter, typename Size, typename FwdIter, typename Sent2>
hpx::parallel::util::in_out_result<InIter, FwdIter> uninitialized_move_n(InIter first1, Size count, FwdIter first2, Sent2 last2)

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

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

Parameters
  • first1: Refers to the beginning of the sequence of elements that will be moved from

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

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

  • last2: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

Return

The uninitialized_move_n algorithm returns in_out_result<InIter, FwdIter>. The uninitialized_move_n 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, typename Sent2>
parallel::util::detail::algorithm_result<ExPolicy, parallel::util::in_out_result<FwdIter1, FwdIter2>>::type uninitialized_move_n(ExPolicy &&policy, FwdIter1 first1, Size count, FwdIter2 first2, Sent2 last2)

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

  • Sent2: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter2.

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

  • first1: Refers to the beginning of the sequence of elements that will be moved from

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

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

  • last1: Refers to sentinel value denoting the end of the second range the algorithm will be applied to.

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<in_out_result<FwdIter1, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The uninitialized_move_n algorithm returns the output iterator to the element in the destination range, one past the last element moved.

namespace hpx
namespace ranges

Functions

template<typename FwdIter, typename Sent>
FwdIter uninitialized_value_construct(FwdIter first, Sent last)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range by value-initialization. If an exception is thrown during the initialization, the function has no effects.

The assignments in the parallel

uninitialized_value_construct algorithm invoked without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

Template Parameters
  • FwdIter: The type of the source iterators used (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 FwdIter.

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

  • last: Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

Return

The uninitialized_value_construct algorithm returns a returns FwdIter. The uninitialized_value_construct algorithm returns the output iterator to the element in the range, one past the last element constructed.

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

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range by value-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.

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

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 sentinel value denoting the end of the sequence of elements the algorithm will be applied.

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<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The uninitialized_value_construct algorithm returns the iterator to the element in the source range, one past the last element constructed.

template<typename Rng>
hpx::traits::range_traits<Rng>::iterator_type uninitialized_value_construct(Rng &&rng)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range by value-initialization. If an exception is thrown during the initialization, the function has no effects.

The assignments in the parallel

uninitialized_value_construct algorithm invoked without an execution policy object will execute in sequential order in the calling thread.
Note

Complexity: Performs exactly last - first assignments.

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

Parameters
  • rng: Refers to the range to which will be value constructed.

Return

The uninitialized_value_construct algorithm returns a returns hpx::traits::range_traits<Rng> ::iterator_type. The uninitialized_value_construct algorithm returns the output iterator to the element in the range, one past the last element constructed.

template<typename ExPolicy, typename Rng>
parallel::util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_type>::type uninitialized_value_construct(ExPolicy &&policy, Rng &&rng)

Constructs objects of type typename iterator_traits<ForwardIt> ::value_type in the uninitialized storage designated by the range by value-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.

  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

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

  • rng: Refers to the range to which the value will be value consutrcted

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<typename hpx::traits::range_traits<Rng> ::iterator_type>, if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns typename hpx::traits::range_traits<Rng>::iterator_type otherwise. The uninitialized_value_construct algorithm returns the output iterator to the element in the range, one past the last element constructed.

template<typename FwdIter, typename Size>
FwdIter uninitialized_value_construct_n(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 value-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 without an execution policy object execute in sequential order in the calling thread.
Note

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

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

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

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.

Return

The uninitialized_value_construct_n algorithm returns a returns FwdIter. The uninitialized_value_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

template<typename ExPolicy, typename FwdIter, typename Size>
parallel::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 value-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 Rng, typename Pred = detail::equal_to, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type unique(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Eliminates all but the first element from every consecutive group of equivalent elements from the range rng 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 N assignments, exactly N - 1 applications of the predicate pred and no more than twice as many applications of the projection proj, where N = std::distance(begin(rng), end(rng)).

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.

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

  • rng: Refers to 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 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 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 Rng, typename FwdIter2, typename Pred = detail::equal_to, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_iterator<Rng>::type), tag::out(FwdIter2)>>::type unique_copy(ExPolicy &&policy, Rng &&rng, FwdIter2 dest, Pred &&pred = Pred(), Proj &&proj = Proj())

Copies the elements from the range rng, 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 N assignments, exactly N - 1 applications of the predicate pred, where N = std::distance(begin(rng), end(rng)).

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.

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

  • rng: Refers to 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 the range rng. 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 parallel
namespace util
template<typename T = detail::no_data, typename Pred = std::less_equal<T>>
class cancellation_token

Public Functions

cancellation_token(T data)
bool was_cancelled(T data) const
void cancel(T data)
T get_data() const

Private Types

typedef std::atomic<T> flag_type

Private Members

std::shared_ptr<flag_type> was_cancelled_
template<typename Compare>
struct compare_projected<Compare, util::projection_identity>

Public Functions

template<typename Compare_>
constexpr compare_projected(Compare_ &&comp, util::projection_identity)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
template<typename Compare, typename Proj2>
struct compare_projected<Compare, util::projection_identity, Proj2>

Public Functions

template<typename Compare_, typename Proj2_>
constexpr compare_projected(Compare_ &&comp, util::projection_identity, Proj2_ &&proj2)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj2 proj2_
template<typename Compare, typename Proj1>
struct compare_projected<Compare, Proj1, util::projection_identity>

Public Functions

template<typename Compare_, typename Proj1_>
constexpr compare_projected(Compare_ &&comp, Proj1_ &&proj1, util::projection_identity)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj1 proj1_
template<typename Compare>
struct compare_projected<Compare, util::projection_identity, util::projection_identity>

Public Functions

template<typename Compare_>
constexpr compare_projected(Compare_ &&comp, util::projection_identity, util::projection_identity)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
namespace hpx
namespace parallel
namespace util
template<typename Compare, typename Proj>
struct compare_projected<Compare, Proj>

Public Functions

template<typename Compare_, typename Proj_>
constexpr compare_projected(Compare_ &&comp, Proj_ &&proj)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj proj_
template<typename Compare, typename Proj1, typename Proj2>
struct compare_projected<Compare, Proj1, Proj2>

Public Functions

template<typename Compare_, typename Proj1_, typename Proj2_>
constexpr compare_projected(Compare_ &&comp, Proj1_ &&proj1, Proj2_ &&proj2)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj1 proj1_
Proj2 proj2_
template<typename Compare, typename Proj1>
struct compare_projected<Compare, Proj1, util::projection_identity>

Public Functions

template<typename Compare_, typename Proj1_>
constexpr compare_projected(Compare_ &&comp, Proj1_ &&proj1, util::projection_identity)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj1 proj1_
template<typename Compare>
struct compare_projected<Compare, util::projection_identity>

Public Functions

template<typename Compare_>
constexpr compare_projected(Compare_ &&comp, util::projection_identity)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
template<typename Compare, typename Proj2>
struct compare_projected<Compare, util::projection_identity, Proj2>

Public Functions

template<typename Compare_, typename Proj2_>
constexpr compare_projected(Compare_ &&comp, util::projection_identity, Proj2_ &&proj2)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj2 proj2_
template<typename Compare>
struct compare_projected<Compare, util::projection_identity, util::projection_identity>

Public Functions

template<typename Compare_>
constexpr compare_projected(Compare_ &&comp, util::projection_identity, util::projection_identity)
template<typename T1, typename T2>
constexpr bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
namespace hpx
namespace parallel
namespace util
template<typename Pred, typename Proj>
struct invoke_projected

Public Types

template<>
using pred_type = typename std::decay<Pred>::type
template<>
using proj_type = typename std::decay<Proj>::type

Public Functions

template<typename Pred_, typename Proj_>
invoke_projected(Pred_ &&pred, Proj_ &&proj)
template<typename T>
decltype(auto) operator()(T &&t)
template<typename T>
decltype(auto) operator()(T &&t, T &&u)

Public Members

pred_type pred_
proj_type proj_
template<typename Pred>
struct invoke_projected<Pred, projection_identity>

Public Types

template<>
using pred_type = typename std::decay<Pred>::type

Public Functions

template<typename Pred_>
invoke_projected(Pred_ &&pred, projection_identity)
template<typename T>
decltype(auto) operator()(T &&t)
template<typename T>
bool operator()(T &&t, T &&u)

Public Members

pred_type pred_
namespace hpx
namespace parallel
namespace util

Functions

template<typename Iter, typename F, typename Cleanup>
constexpr Iter loop_with_cleanup(Iter it, Iter last, F &&f, Cleanup &&cleanup)
template<typename Iter, typename FwdIter, typename F, typename Cleanup>
constexpr FwdIter loop_with_cleanup(Iter it, Iter last, FwdIter dest, F &&f, Cleanup &&cleanup)
template<typename Iter, typename F, typename Cleanup>
constexpr Iter loop_with_cleanup_n(Iter it, std::size_t count, F &&f, Cleanup &&cleanup)
template<typename Iter, typename FwdIter, typename F, typename Cleanup>
constexpr FwdIter loop_with_cleanup_n(Iter it, std::size_t count, FwdIter dest, F &&f, Cleanup &&cleanup)
template<typename Iter, typename CancelToken, typename F, typename Cleanup>
constexpr Iter loop_with_cleanup_n_with_token(Iter it, std::size_t count, CancelToken &tok, F &&f, Cleanup &&cleanup)
template<typename Iter, typename FwdIter, typename CancelToken, typename F, typename Cleanup>
constexpr FwdIter loop_with_cleanup_n_with_token(Iter it, std::size_t count, FwdIter dest, CancelToken &tok, F &&f, Cleanup &&cleanup)
template<typename Iter, typename F>
constexpr Iter loop_idx_n(std::size_t base_idx, Iter it, std::size_t count, F &&f)
template<typename Iter, typename CancelToken, typename F>
constexpr Iter loop_idx_n(std::size_t base_idx, Iter it, std::size_t count, CancelToken &tok, F &&f)
template<typename Iter, typename T, typename Pred>
T accumulate_n(Iter it, std::size_t count, T init, Pred &&f)
template<typename T, typename Iter, typename Reduce, typename Conv = util::projection_identity>
T accumulate(Iter first, Iter last, Reduce &&r, Conv &&conv = Conv())
template<typename T, typename Iter1, typename Iter2, typename Reduce, typename Conv>
T accumulate(Iter1 first1, Iter1 last1, Iter2 first2, Reduce &&r, Conv &&conv)

Variables

template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE loop_step_t<ExPolicy> hpx::parallel::util::loop_step=loop_step_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE loop_optimization_t<ExPolicy> hpx::parallel::util::loop_optimization = loop_optimization_t<ExPolicy>{}
HPX_INLINE_CONSTEXPR_VARIABLE loop_t hpx::parallel::util::loop = loop_t{}
HPX_INLINE_CONSTEXPR_VARIABLE loop_ind_t hpx::parallel::util::loop_ind = loop_ind_t{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE loop2_t<ExPolicy> hpx::parallel::util::loop2 = loop2_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE loop_n_t<ExPolicy> hpx::parallel::util::loop_n=loop_n_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE loop_n_ind_t<ExPolicy> hpx::parallel::util::loop_n_ind=loop_n_ind_t<ExPolicy>{}
template<typename ExPolicy>
struct loop2_t : public hpx::functional::tag_fallback<loop2_t<ExPolicy>>

Friends

template<typename VecOnly, typename Begin1, typename End1, typename Begin2, typename F>
friend constexpr std::pair<Begin1, Begin2> tag_fallback_dispatch(hpx::parallel::util::loop2_t<ExPolicy>, VecOnly&&, Begin1 begin1, End1 end1, Begin2 begin2, F &&f)
struct loop_ind_t : public hpx::functional::tag_fallback<loop_ind_t>

Friends

template<typename ExPolicy, typename Begin, typename End, typename F>
friend constexpr Begin tag_fallback_dispatch(hpx::parallel::util::loop_ind_t, ExPolicy&&, Begin begin, End end, F &&f)
template<typename ExPolicy, typename Begin, typename End, typename CancelToken, typename F>
friend constexpr Begin tag_fallback_dispatch(hpx::parallel::util::loop_ind_t, ExPolicy&&, Begin begin, End end, CancelToken &tok, F &&f)
template<typename ExPolicy>
struct loop_n_ind_t : public hpx::functional::tag_fallback<loop_n_ind_t<ExPolicy>>

Friends

template<typename Iter, typename F>
friend constexpr Iter tag_fallback_dispatch(hpx::parallel::util::loop_n_ind_t<ExPolicy>, Iter it, std::size_t count, F &&f)
template<typename Iter, typename CancelToken, typename F>
friend constexpr Iter tag_fallback_dispatch(hpx::parallel::util::loop_n_ind_t<ExPolicy>, Iter it, std::size_t count, CancelToken &tok, F &&f)
template<typename ExPolicy>
struct loop_n_t : public hpx::functional::tag_fallback<loop_n_t<ExPolicy>>

Friends

template<typename Iter, typename F>
friend constexpr Iter tag_fallback_dispatch(hpx::parallel::util::loop_n_t<ExPolicy>, Iter it, std::size_t count, F &&f)
template<typename Iter, typename CancelToken, typename F>
friend constexpr Iter tag_fallback_dispatch(hpx::parallel::util::loop_n_t<ExPolicy>, Iter it, std::size_t count, CancelToken &tok, F &&f)
template<typename ExPolicy>
struct loop_optimization_t : public hpx::functional::tag_fallback<loop_optimization_t<ExPolicy>>

Friends

template<typename Iter>
friend constexpr bool tag_fallback_dispatch(hpx::parallel::util::loop_optimization_t<ExPolicy>, Iter, Iter)
template<typename ExPolicy>
struct loop_step_t : public hpx::functional::tag_fallback<loop_step_t<ExPolicy>>

Friends

template<typename VecOnly, typename F, typename ...Iters>
hpx::util::invoke_result<F, Iters...>::type tag_fallback_dispatch(hpx::parallel::util::loop_step_t<ExPolicy>, VecOnly&&, F &&f, Iters&... its)
struct loop_t : public hpx::functional::tag_fallback<loop_t>

Friends

template<typename ExPolicy, typename Begin, typename End, typename F>
friend constexpr Begin tag_fallback_dispatch(hpx::parallel::util::loop_t, ExPolicy&&, Begin begin, End end, F &&f)
template<typename ExPolicy, typename Begin, typename End, typename CancelToken, typename F>
friend constexpr Begin tag_fallback_dispatch(hpx::parallel::util::loop_t, ExPolicy&&, Begin begin, End end, CancelToken &tok, F &&f)
namespace hpx
namespace parallel
namespace util

Functions

template<typename Value, typename ...Args>
void construct_object(Value *ptr, Args&&... args)

create an object in the memory specified by ptr

Template Parameters
  • Value: : typename of the object to create

  • Args: : parameters for the constructor

Parameters
  • [in] ptr: : pointer to the memory where to create the object

  • [in] args: : arguments to the constructor

template<typename Value>
void destroy_object(Value *ptr)

destroy an object in the memory specified by ptr

Template Parameters
  • Value: : typename of the object to create

Parameters
  • [in] ptr: : pointer to the object to destroy

template<typename Iter, typename Sent>
void init(Iter first, Sent last, typename std::iterator_traits<Iter>::value_type &val)

Initialize a range of objects with the object val moving across them

Return

range initialized

Parameters
  • [in] r: : range of elements not initialized

  • [in] val: : object used for the initialization

template<typename Value, typename ...Args>
void construct(Value *ptr, Args&&... args)

create an object in the memory specified by ptr

Template Parameters
  • Value: : typename of the object to create

  • Args: : parameters for the constructor

Parameters
  • [in] ptr: : pointer to the memory where to create the object

  • [in] args: : arguments to the constructor

template<typename Iter1, typename Sent1, typename Iter2>
Iter2 init_move(Iter2 it_dest, Iter1 first, Sent1 last)

Move objects.

Template Parameters
  • Iter: : iterator to the elements

  • Value: : typename of the object to create

Parameters
  • [in] itdest: : iterator to the final place of the objects

  • [in] R: : range to move

template<typename Iter, typename Sent, typename Value = typename std::iterator_traits<Iter>::value_type>
Value *uninit_move(Value *ptr, Iter first, Sent last)

Move objects to uninitialized memory.

Template Parameters
  • Iter: : iterator to the elements

  • Value: : typename of the object to construct

Parameters
  • [in] ptr: : pointer to the memory where to create the object

  • [in] R: : range to move

template<typename Iter, typename Sent>
void destroy(Iter first, Sent last)

Move objects to uninitialized memory.

Template Parameters
  • Iter: : iterator to the elements

  • Value: : typename of the object to construct

Parameters
  • [in] ptr: : pointer to the memory where to construct the object

  • [in] R: : range to move

template<typename Iter1, typename Sent1, typename Iter2, typename Compare>
Iter2 full_merge(Iter1 buf1, Sent1 end_buf1, Iter1 buf2, Sent1 end_buf2, Iter2 buf_out, Compare comp)

Merge two contiguous buffers pointed by buf1 and buf2 , and put in the buffer pointed by buf_out.

Parameters
  • [in] buf1: : iterator to the first element in the first buffer

  • [in] end_buf1: : final iterator of first buffer

  • [in] buf2: : iterator to the first iterator to the second buffer

  • [in] end_buf2: : final iterator of the second buffer

  • [in] buf_out: : buffer where move the elements merged

  • [in] comp: : comparison object

template<typename Iter, typename Sent, typename Value, typename Compare>
Value *uninit_full_merge(Iter first1, Sent last1, Iter first2, Sent last2, Value *it_out, Compare comp)

Merge two contiguous buffers pointed by first1 and first2 , and put in the uninitialized buffer pointed by it_out.

Parameters
  • [in] first1: : iterator to the first element in the first buffer

  • [in] last: : last iterator of the first buffer

  • [in] first2: : iterator to the first element to the second buffer

  • [in] last22: : final iterator of the second buffer

  • [in] it_out: : uninitialized buffer where move the elements merged

  • [in] comp: : comparison object

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
Iter2 half_merge(Iter1 buf1, Sent1 end_buf1, Iter2 buf2, Sent2 end_buf2, Iter2 buf_out, Compare comp)

: Merge two buffers. The first buffer is in a separate memory. The second buffer have a empty space before buf2 of the same size than the (end_buf1 - buf1)

Remark

The elements pointed by Iter1 and Iter2 must be the same

Parameters
  • [in] buf1: : iterator to the first element of the first buffer

  • [in] end_buf1: : iterator to the last element of the first buffer

  • [in] buf2: : iterator to the first element of the second buffer

  • [in] end_buf2: : iterator to the last element of the second buffer

  • [in] buf_out: : iterator to the first element to the buffer where put the result

  • [in] comp: : object for Compare two elements of the type pointed by the Iter1 and Iter2

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Compare>
bool in_place_merge_uncontiguous(Iter1 src1, Sent1 end_src1, Iter2 src2, Sent2 end_src2, Iter3 aux, Compare comp)

Merge two non contiguous buffers, placing the results in the buffers for to do this use an auxiliary buffer pointed by aux

Parameters
  • [in] src1: : iterator to the first element of the first buffer

  • [in] end_src1: : last iterator of the first buffer

  • [in] src2: : iterator to the first element of the second buffer

  • [in] end_src2: : last iterator of the second buffer

  • [in] aux: : iterator to the first element of the auxiliary buffer

  • [in] comp: : object for to Compare elements

Exceptions

template<typename Iter1, typename Sent1, typename Iter2, typename Compare>
bool in_place_merge(Iter1 src1, Iter1 src2, Sent1 end_src2, Iter2 buf, Compare comp)

: merge two contiguous buffers,using an auxiliary buffer pointed by buf

Parameters
  • [in] src1: iterator to the first position of the first buffer

  • [in] src2: final iterator of the first buffer and first iterator of the second buffer

  • [in] end_src2: : final iterator of the second buffer

  • [in] buf: : iterator to buffer used as auxiliary memory

  • [in] comp: : object for to Compare elements

Exceptions

namespace hpx
namespace parallel
namespace util

Functions

template<typename Iter, typename Sent, typename Compare>
bool less_range(Iter it1, std::uint32_t pos1, Sent it2, std::uint32_t pos2, Compare comp)

Compare the elements pointed by it1 and it2, and if they are equals, compare their position, doing a stable comparison.

Return

result of the comparison

Parameters
  • [in] it1: : iterator to the first element

  • [in] pos1: : position of the object pointed by it1

  • [in] it2: : iterator to the second element

  • [in] pos2: : position of the element pointed by it2

  • [in] comp: : comparison object

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
util::range<Iter1, Sent1> full_merge4(util::range<Iter1, Sent1> &rdest, util::range<Iter2, Sent2> vrange_input[4], std::uint32_t nrange_input, Compare comp)

Merge four ranges.

Return

range with all the elements move with the size adjusted

Parameters
  • [in] dest: range where move the elements merged. Their size must be greater or equal than the sum of the sizes of the ranges in the array R

  • [in] R: : array of ranges to merge

  • [in] nrange_input: : number of ranges in R

  • [in] comp: : comparison object

template<typename Value, typename Iter, typename Sent, typename Compare>
util::range<Value*> uninit_full_merge4(util::range<Value*> const &dest, util::range<Iter, Sent> vrange_input[4], std::uint32_t nrange_input, Compare comp)

Merge four ranges and put the result in uninitialized memory.

Return

range with all the elements move with the size adjusted

Parameters
  • [in] dest: range where create and move the elements merged. Their size must be greater or equal than the sum of the sizes of the ranges in the array R

  • [in] R: : array of ranges to merge

  • [in] nrange_input: : number of ranges in vrange_input

  • [in] comp: : comparison object

namespace hpx
namespace parallel
namespace util

Functions

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
void merge_level4(util::range<Iter1, Sent1> dest, std::vector<util::range<Iter2, Sent2>> &v_input, std::vector<util::range<Iter1, Sent1>> &v_output, Compare comp)

Merge the ranges in the vector v_input using full_merge4. The v_output vector is used as auxiliary memory in the internal process The final results is in the dest range. All the ranges of v_output are inside the range dest

Return

range with all the elements moved

Parameters
  • [in] dest: : range where move the elements merged

  • [in] v_input: : vector of ranges to merge

  • [in] v_output: : vector of ranges obtained

  • [in] comp: : comparison object

template<typename Value, typename Iter, typename Sent, typename Compare>
void uninit_merge_level4(util::range<Value*> dest, std::vector<util::range<Iter, Sent>> &v_input, std::vector<util::range<Value*>> &v_output, Compare comp)

Merge the ranges over uninitialized memory,in the vector v_input using full_merge4. The v_output vector is used as auxiliary memory in the internal process. The final results is in the dest range. All the ranges of v_output are inside the range dest

Return

range with all the elements moved

Parameters
  • [in] dest: : range where move the elements merged

  • [in] v_input: : vector of ranges to merge

  • [in] v_output: : vector of ranges obtained

  • [in] comp: : comparison object

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
util::range<Iter2, Sent2> merge_vector4(util::range<Iter1, Sent1> range_input, util::range<Iter2, Sent2> range_output, std::vector<util::range<Iter1, Sent1>> &v_input, std::vector<util::range<Iter2, Sent2>> &v_output, Compare comp)

Merge the ranges in the vector v_input using merge_level4. The v_output vector is used as auxiliary memory in the internal process The final results is in the range_output range. All the ranges of v_output are inside the range range_output All the ranges of v_input are inside the range range_input

Parameters
  • [in] range_input: : range including all the ranges of v_input

namespace hpx
namespace parallel
namespace util

Functions

constexpr std::uint32_t nbits32(std::uint32_t num)

Obtain the number of bits equal or greater than num.

Return

Number of bits

Parameters
  • [in] num: : Number to examine

Exceptions
  • none:

constexpr std::uint32_t nbits64(std::uint64_t num)

Obtain the number of bits equal or greater than num.

Return

Number of bits

Parameters
  • [in] num: : Number to examine

Exceptions
  • none:

Variables

HPX_INLINE_CONSTEXPR_VARIABLE const std::uint32_t hpx::parallel::util::tmsb[256]= {0, 1, 2, 2,        3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,        5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,        6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,        7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}
namespace hpx
namespace parallel
namespace util

Functions

template<typename Itr, typename ...Ts>
prefetching::prefetcher_context<Itr, Ts const...> make_prefetcher_context(Itr base_begin, Itr base_end, std::size_t p_factor, Ts const&... rngs)
namespace prefetching

Functions

template<typename ...Ts, std::size_t... Is>
void prefetch_containers(hpx::tuple<Ts...> const &t, hpx::util::index_pack<Is...>, std::size_t idx)
template<typename ExPolicy, typename Itr, typename ...Ts, typename F>
constexpr prefetching_iterator<Itr, Ts...> tag_dispatch(hpx::parallel::util::loop_n_t<ExPolicy>, prefetching_iterator<Itr, Ts...> it, std::size_t count, F &&f)
template<typename ExPolicy, typename Itr, typename ...Ts, typename F>
constexpr prefetching_iterator<Itr, Ts...> tag_dispatch(hpx::parallel::util::loop_n_ind_t<ExPolicy>, prefetching_iterator<Itr, Ts...> it, std::size_t count, F &&f)
struct loop_n_helper

Public Static Functions

template<typename Itr, typename ...Ts, typename F, typename Pred>
static constexpr prefetching_iterator<Itr, Ts...> call(prefetching_iterator<Itr, Ts...> it, std::size_t count, F &&f, Pred)
template<typename Itr, typename ...Ts, typename CancelToken, typename F, typename Pred>
static constexpr prefetching_iterator<Itr, Ts...> call(prefetching_iterator<Itr, Ts...> it, std::size_t count, CancelToken &tok, F &&f, Pred)
struct loop_n_ind_helper

Public Static Functions

template<typename Itr, typename ...Ts, typename F, typename Pred>
static constexpr prefetching_iterator<Itr, Ts...> call(prefetching_iterator<Itr, Ts...> it, std::size_t count, F &&f, Pred)
template<typename Itr, typename ...Ts, typename CancelToken, typename F, typename Pred>
static constexpr prefetching_iterator<Itr, Ts...> call(prefetching_iterator<Itr, Ts...> it, std::size_t count, CancelToken &tok, F &&f, Pred)
template<typename Itr, typename ...Ts>
struct prefetcher_context

Public Functions

prefetcher_context(Itr begin, Itr end, ranges_type const &rngs, std::size_t p_factor = 1)
prefetching_iterator<Itr, Ts...> begin()
prefetching_iterator<Itr, Ts...> end()

Private Types

typedef hpx::tuple<std::reference_wrapper<Ts>...> ranges_type

Private Members

Itr it_begin_
Itr it_end_
ranges_type rngs_
std::size_t chunk_size_
std::size_t range_size_

Private Static Attributes

constexpr std::size_t sizeof_first_value_type = sizeof(typename hpx::tuple_element<0, ranges_type>::type::type)
template<typename Itr, typename ...Ts>
class prefetching_iterator : public std::iterator<std::random_access_iterator_tag, std::iterator_traits<Itr>::value_type>

Public Types

typedef Itr base_iterator
typedef std::random_access_iterator_tag iterator_category
typedef std::iterator_traits<Itr>::value_type value_type
typedef std::ptrdiff_t difference_type
typedef value_type *pointer
typedef value_type &reference

Public Functions

prefetching_iterator(std::size_t idx, base_iterator base, std::size_t chunk_size, std::size_t range_size, ranges_type const &rngs)
ranges_type const &ranges() const
Itr base() const
std::size_t chunk_size() const
std::size_t range_size() const
std::size_t index() const
prefetching_iterator &operator+=(difference_type rhs)
prefetching_iterator &operator-=(difference_type rhs)
prefetching_iterator &operator++()
prefetching_iterator &operator--()
prefetching_iterator operator++(int)
prefetching_iterator operator--(int)
difference_type operator-(const prefetching_iterator &rhs) const
bool operator==(const prefetching_iterator &rhs) const
bool operator!=(const prefetching_iterator &rhs) const
bool operator>(const prefetching_iterator &rhs) const
bool operator<(const prefetching_iterator &rhs) const
bool operator>=(const prefetching_iterator &rhs) const
bool operator<=(const prefetching_iterator &rhs) const
std::size_t &operator[](std::size_t)
std::size_t operator*() const

Private Types

typedef hpx::tuple<std::reference_wrapper<Ts>...> ranges_type

Private Members

ranges_type rngs_
base_iterator base_
std::size_t chunk_size_
std::size_t range_size_
std::size_t idx_

Friends

prefetching_iterator operator+(prefetching_iterator const &lhs, difference_type rhs)
prefetching_iterator operator-(prefetching_iterator const &lhs, difference_type rhs)
namespace hpx

Typedefs

using identity = hpx::parallel::util::projection_identity
namespace parallel
namespace util
struct projection_identity

Public Types

using is_transparent = std::true_type

Public Functions

template<typename T>
constexpr T &&operator()(T &&val) const
namespace hpx
namespace parallel
namespace util

Typedefs

template<typename Iterator, typename Sentinel = Iterator>
using range = hpx::util::iterator_range<Iterator, Sentinel>

Functions

template<typename Iter, typename Sent>
range<Iter, Sent> concat(range<Iter, Sent> const &it1, range<Iter, Sent> const &it2)

concatenate two contiguous ranges

Return

range resulting of the concatenation

Parameters
  • [in] it1: : first range

  • [in] it2: : second range

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2>
range<Iter2, Iter2> init_move(range<Iter2, Sent2> const &dest, range<Iter1, Sent1> const &src)

Move objects from the range src to dest.

Return

range with the objects moved and the size adjusted

Parameters
  • [in] dest: : range where move the objects

  • [in] src: : range from where move the objects

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2>
range<Iter2, Sent2> uninit_move(range<Iter2, Sent2> const &dest, range<Iter1, Sent1> const &src)

Move objects from the range src creating them in dest.

Return

range with the objects moved and the size adjusted

Parameters
  • [in] dest: : range where move and create the objects

  • [in] src: : range from where move the objects

template<typename Iter, typename Sent>
void destroy_range(range<Iter, Sent> r)

destroy a range of objects

Parameters
  • [in] r: : range to destroy

template<typename Iter, typename Sent>
range<Iter, Sent> init(range<Iter, Sent> const &r, typename std::iterator_traits<Iter>::value_type &val)

initialize a range of objects with the object val moving across them

Return

range initialized

Parameters
  • [in] r: : range of elements not initialized

  • [in] val: : object used for the initialization

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
bool is_mergeable(range<Iter1, Sent1> const &src1, range<Iter2, Sent2> const &src2, Compare comp)

: indicate if two ranges have a possible merge

Parameters
  • [in] src1: : first range

  • [in] src2: : second range

  • [in] comp: : object for to compare elements

Exceptions

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Sent3, typename Compare>
range<Iter3, Sent3> full_merge(range<Iter3, Sent3> const &dest, range<Iter1, Sent1> const &src1, range<Iter2, Sent2> const &src2, Compare comp)

Merge two contiguous ranges src1 and src2 , and put the result in the range dest, returning the range merged.

Return

range with the elements merged and the size adjusted

Parameters
  • [in] dest: : range where locate the lements merged. the size of dest must be greater or equal than the sum of the sizes of src1 and src2

  • [in] src1: : first range to merge

  • [in] src2: : second range to merge

  • [in] comp: : comparison object

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Value, typename Compare>
range<Value*> uninit_full_merge(const range<Value*> &dest, range<Iter1, Sent1> const &src1, range<Iter2, Sent2> const &src2, Compare comp)

Merge two contiguous ranges src1 and src2 , and create and move the result in the uninitialized range dest, returning the range merged.

Return

range with the elements merged and the size adjusted

Parameters
  • [in] dest: : range where locate the elements merged. the size of dest must be greater or equal than the sum of the sizes of src1 and src2. Initially is uninitialize memory

  • [in] src1: : first range to merge

  • [in] src2: : second range to merge

  • [in] comp: : comparison object

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
range<Iter2, Sent2> half_merge(range<Iter2, Sent2> const &dest, range<Iter1, Sent1> const &src1, range<Iter2, Sent2> const &src2, Compare comp)

: Merge two buffers. The first buffer is in a separate memory

Return

: range with the two buffers merged

Parameters
  • [in] dest: : range where finish the two buffers merged

  • [in] src1: : first range to merge in a separate memory

  • [in] src2: : second range to merge, in the final part of the range where deposit the final results

  • [in] comp: : object for compare two elements of the type pointed by the Iter1 and Iter2

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Sent3, typename Compare>
bool in_place_merge_uncontiguous(range<Iter1, Sent1> const &src1, range<Iter2, Sent2> const &src2, range<Iter3, Sent3> &aux, Compare comp)

: merge two non contiguous buffers src1 , src2, using the range aux as auxiliary memory

Parameters
  • [in] src1: : first range to merge

  • [in] src2: : second range to merge

  • [in] aux: : auxiliary range used in the merge

  • [in] comp: : object for to compare elements

Exceptions

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
range<Iter1, Sent1> in_place_merge(range<Iter1, Sent1> const &src1, range<Iter1, Sent1> const &src2, range<Iter2, Sent2> &buf, Compare comp)

: merge two contiguous buffers ( src1, src2) using buf as auxiliary memory

Parameters
  • [in] src1: : first range to merge

  • [in] src1: : second range to merge

  • [in] buf: : auxiliary memory used in the merge

  • [in] comp: : object for to compare elements

Exceptions

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Compare>
void merge_flow(range<Iter1, Sent1> rng1, range<Iter2, Sent2> rbuf, range<Iter1, Sent1> rng2, Compare cmp)

: merge two contiguous buffers

Template Parameters
  • Iter: : iterator to the elements

  • compare: : object for to compare two elements pointed by Iter iterators

Parameters
  • [in] first: : iterator to the first element

  • [in] last: : iterator to the element after the last in the range

  • [in] comp: : object for to compare elements

Exceptions

namespace hpx
namespace ranges

Functions

template<typename Iter>
constexpr Iter next(Iter first, typename std::iterator_traits<Iter>::difference_type dist = 1)
template<typename Iter, typename Sent>
constexpr Iter next(Iter first, Sent bound)
template<typename Iter, typename Sent>
constexpr Iter next_(Iter first, typename std::iterator_traits<Iter>::difference_type n, Sent bound)
template<typename Iter, typename Sent>
constexpr Iter next_(Iter first, typename std::iterator_traits<Iter>::difference_type n, Sent bound, std::true_type, std::true_type)
template<typename Iter, typename Sent>
constexpr Iter next(Iter first, typename std::iterator_traits<Iter>::difference_type n, Sent bound)
namespace hpx
namespace parallel
namespace util

Functions

template<typename I, typename O>
std::pair<I, O> get_pair(util::in_out_result<I, O> &&p)
template<typename I, typename O>
O get_second_element(util::in_out_result<I, O> &&p)
template<typename I, typename O>
hpx::future<std::pair<I, O>> get_pair(hpx::future<util::in_out_result<I, O>> &&f)
template<typename I, typename O>
hpx::future<O> get_second_element(hpx::future<util::in_out_result<I, O>> &&f)
template<typename I1, typename I2, typename O>
O get_third_element(util::in_in_out_result<I1, I2, O> &&p)
template<typename I1, typename I2, typename O>
hpx::future<O> get_third_element(hpx::future<util::in_in_out_result<I1, I2, O>> &&f)
template<typename Iterator, typename Sentinel = Iterator>
hpx::util::iterator_range<Iterator, Sentinel> make_subrange(Iterator iterator, Sentinel sentinel)
template<typename Iterator, typename Sentinel = Iterator>
hpx::future<hpx::util::iterator_range<Iterator, Sentinel>> make_subrange(hpx::future<Iterator> &&iterator, Sentinel sentinel)
template<typename I, typename F>
struct in_fun_result

Public Functions

template<typename I2, typename F2, typename Enable = typename std::enable_if<std::is_convertible<I const&, I2>::value && std::is_convertible<F const&, F2>::value>::type>
constexpr operator in_fun_result<I2, F2>() const &
template<typename I2, typename F2, typename Enable = typename std::enable_if<std::is_convertible<I, I2>::value && std::is_convertible<F, F2>::value>::type>
constexpr operator in_fun_result<I2, F2>() &&
template<typename Archive>
void serialize(Archive &ar, unsigned)

Public Members

HPX_NO_UNIQUE_ADDRESS I hpx::parallel::util::in_fun_result::in
HPX_NO_UNIQUE_ADDRESS F hpx::parallel::util::in_fun_result::fun
template<typename I1, typename I2, typename O>
struct in_in_out_result

Public Functions

template<typename II1, typename II2, typename O1, typename Enable = typename std::enable_if<std::is_convertible<I1 const&, II1>::value && std::is_convertible<I2 const&, II2>::value && std::is_convertible<O const&, O1>::value>::type>
constexpr operator in_in_out_result<II1, II2, O1>() const &
template<typename II2, typename II1, typename O1, typename Enable = typename std::enable_if<std::is_convertible<I1, II1>::value && std::is_convertible<I2, II2>::value && std::is_convertible<O, O1>::value>::type>
constexpr operator in_in_out_result<II1, II2, O1>() &&
template<typename Archive>
void serialize(Archive &ar, unsigned)

Public Members

HPX_NO_UNIQUE_ADDRESS I1 hpx::parallel::util::in_in_out_result::in1
HPX_NO_UNIQUE_ADDRESS I2 hpx::parallel::util::in_in_out_result::in2
HPX_NO_UNIQUE_ADDRESS O hpx::parallel::util::in_in_out_result::out
template<typename I1, typename I2>
struct in_in_result

Public Functions

template<typename II1, typename II2, typename Enable = typename std::enable_if<std::is_convertible<I1 const&, II1>::value && std::is_convertible<I2 const&, II2>::value>::type>
constexpr operator in_in_result<II1, II2>() const &
template<typename II1, typename II2, typename Enable = typename std::enable_if<std::is_convertible<I1, II1>::value && std::is_convertible<I2, II2>::value>::type>
constexpr operator in_in_result<II1, II2>() &&
template<typename Archive>
void serialize(Archive &ar, unsigned)

Public Members

HPX_NO_UNIQUE_ADDRESS I1 hpx::parallel::util::in_in_result::in1
HPX_NO_UNIQUE_ADDRESS I2 hpx::parallel::util::in_in_result::in2
template<typename I, typename O>
struct in_out_result

Public Functions

template<typename I2, typename O2, typename Enable = typename std::enable_if<std::is_convertible<I const&, I2>::value && std::is_convertible<O const&, O2>::value>::type>
constexpr operator in_out_result<I2, O2>() const &
template<typename I2, typename O2, typename Enable = typename std::enable_if<std::is_convertible<I, I2>::value && std::is_convertible<O, O2>::value>::type>
constexpr operator in_out_result<I2, O2>() &&
template<typename Archive>
void serialize(Archive &ar, unsigned)

Public Members

HPX_NO_UNIQUE_ADDRESS I hpx::parallel::util::in_out_result::in
HPX_NO_UNIQUE_ADDRESS O hpx::parallel::util::in_out_result::out
namespace hpx
namespace util

Functions

template<typename Tag1, typename Tag2, typename T1, typename T2>
hpx::future<tagged_pair<Tag1(typename std::decay<T1>::type), Tag2(typename std::decay<T2>::type)>> make_tagged_pair(hpx::future<std::pair<T1, T2>> &&f)
template<typename Tag1, typename Tag2, typename ...Ts>
hpx::future<tagged_pair<Tag1(typename hpx::tuple_element<0, hpx::tuple<Ts...>>::type), Tag2(typename hpx::tuple_element<1, hpx::tuple<Ts...>>::type)>> make_tagged_pair(hpx::future<hpx::tuple<Ts...>> &&f)
namespace hpx
namespace util

Functions

template<typename ...Tags, typename ...Ts>
hpx::future<typename detail::tagged_tuple_helper<hpx::tuple<Ts...>, typename util::make_index_pack<sizeof...(Tags)>::type, Tags...>::type> make_tagged_tuple(hpx::future<hpx::tuple<Ts...>> &&f)
namespace hpx
namespace parallel
namespace util

Functions

template<typename InIter, typename Sent, typename OutIter>
constexpr in_out_result<InIter, OutIter> copy(InIter first, Sent last, OutIter dest)
template<typename InIter, typename OutIter>
constexpr in_out_result<InIter, OutIter> copy_n(InIter first, std::size_t count, OutIter dest)
template<typename InIter, typename OutIter>
constexpr void copy_synchronize(InIter const &first, OutIter const &dest)
template<typename InIter, typename Sent, typename OutIter>
constexpr in_out_result<InIter, OutIter> move(InIter first, Sent last, OutIter dest)
template<typename InIter, typename OutIter>
constexpr in_out_result<InIter, OutIter> move_n(InIter first, std::size_t count, OutIter dest)
namespace hpx
namespace parallel
namespace util

Variables

HPX_INLINE_CONSTEXPR_VARIABLE transform_loop_t hpx::parallel::util::transform_loop=transform_loop_t{}
HPX_INLINE_CONSTEXPR_VARIABLE transform_loop_ind_t hpx::parallel::util::transform_loop_ind=transform_loop_ind_t{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE transform_binary_loop_t<ExPolicy> hpx::parallel::util::transform_binary_loop = transform_binary_loop_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE transform_binary_loop_ind_t<ExPolicy> hpx::parallel::util::transform_binary_loop_ind = transform_binary_loop_ind_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE transform_loop_n_t<ExPolicy> hpx::parallel::util::transform_loop_n = transform_loop_n_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE transform_loop_n_ind_t<ExPolicy> hpx::parallel::util::transform_loop_n_ind = transform_loop_n_ind_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE transform_binary_loop_n_t<ExPolicy> hpx::parallel::util::transform_binary_loop_n = transform_binary_loop_n_t<ExPolicy>{}
template<typename ExPolicy>HPX_INLINE_CONSTEXPR_VARIABLE transform_binary_loop_ind_n_t<ExPolicy> hpx::parallel::util::transform_binary_loop_ind_n = transform_binary_loop_ind_n_t<ExPolicy>{}
template<typename ExPolicy>
struct transform_binary_loop_ind_n_t : public hpx::functional::tag_fallback<transform_binary_loop_ind_n_t<ExPolicy>>

Friends

template<typename InIter1, typename InIter2, typename OutIter, typename F>
friend constexpr hpx::tuple<InIter1, InIter2, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_binary_loop_ind_n_t<ExPolicy>, InIter1 first1, std::size_t count, InIter2 first2, OutIter dest, F &&f)
template<typename ExPolicy>
struct transform_binary_loop_ind_t : public hpx::functional::tag_fallback<transform_binary_loop_ind_t<ExPolicy>>

Friends

template<typename InIter1B, typename InIter1E, typename InIter2, typename OutIter, typename F>
friend constexpr util::in_in_out_result<InIter1B, InIter2, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_binary_loop_ind_t<ExPolicy>, InIter1B first1, InIter1E last1, InIter2 first2, OutIter dest, F &&f)
template<typename InIter1B, typename InIter1E, typename InIter2B, typename InIter2E, typename OutIter, typename F>
friend constexpr util::in_in_out_result<InIter1B, InIter2B, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_binary_loop_ind_t<ExPolicy>, InIter1B first1, InIter1E last1, InIter2B first2, InIter2E last2, OutIter dest, F &&f)
template<typename ExPolicy>
struct transform_binary_loop_n_t : public hpx::functional::tag_fallback<transform_binary_loop_n_t<ExPolicy>>

Friends

template<typename InIter1, typename InIter2, typename OutIter, typename F>
friend constexpr hpx::tuple<InIter1, InIter2, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_binary_loop_n_t<ExPolicy>, InIter1 first1, std::size_t count, InIter2 first2, OutIter dest, F &&f)
template<typename ExPolicy>
struct transform_binary_loop_t : public hpx::functional::tag_fallback<transform_binary_loop_t<ExPolicy>>

Friends

template<typename InIter1B, typename InIter1E, typename InIter2, typename OutIter, typename F>
friend constexpr util::in_in_out_result<InIter1B, InIter2, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_binary_loop_t<ExPolicy>, InIter1B first1, InIter1E last1, InIter2 first2, OutIter dest, F &&f)
template<typename InIter1B, typename InIter1E, typename InIter2B, typename InIter2E, typename OutIter, typename F>
friend constexpr util::in_in_out_result<InIter1B, InIter2B, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_binary_loop_t<ExPolicy>, InIter1B first1, InIter1E last1, InIter2B first2, InIter2E last2, OutIter dest, F &&f)
struct transform_loop_ind_t : public hpx::functional::tag_fallback<transform_loop_ind_t>

Friends

template<typename ExPolicy, typename IterB, typename IterE, typename OutIter, typename F>
friend constexpr util::in_out_result<IterB, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_loop_ind_t, ExPolicy&&, IterB it, IterE end, OutIter dest, F &&f)
template<typename ExPolicy>
struct transform_loop_n_ind_t : public hpx::functional::tag_fallback<transform_loop_n_ind_t<ExPolicy>>

Friends

template<typename Iter, typename OutIter, typename F>
friend constexpr std::pair<Iter, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_loop_n_ind_t<ExPolicy>, Iter it, std::size_t count, OutIter dest, F &&f)
template<typename ExPolicy>
struct transform_loop_n_t : public hpx::functional::tag_fallback<transform_loop_n_t<ExPolicy>>

Friends

template<typename Iter, typename OutIter, typename F>
friend constexpr std::pair<Iter, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_loop_n_t<ExPolicy>, Iter it, std::size_t count, OutIter dest, F &&f)
struct transform_loop_t : public hpx::functional::tag_fallback<transform_loop_t>

Friends

template<typename ExPolicy, typename IterB, typename IterE, typename OutIter, typename F>
friend constexpr util::in_out_result<IterB, OutIter> tag_fallback_dispatch(hpx::parallel::util::transform_loop_t, ExPolicy&&, IterB it, IterE end, OutIter dest, F &&f)