algorithms

#include <hpx/traits/segmented_iterator_traits.hpp>

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)

#include <hpx/traits/is_value_proxy.hpp>

#include <hpx/parallel/datapar.hpp>

#include <hpx/parallel/tagspec.hpp>

#include <hpx/parallel/numeric.hpp>

#include <hpx/parallel/memory.hpp>

#include <hpx/parallel/container_algorithms.hpp>

#include <hpx/parallel/algorithm.hpp>

#include <hpx/parallel/container_algorithms/partition.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/container_algorithms/rotate.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::begin(typename hpx::traits::range_iterator<Rng>::type), tag::end(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, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_iterator<Rng>::type), tag::out(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.

#include <hpx/parallel/container_algorithms/all_any_none.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/container_algorithms/find.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename Rng2, typename Pred = detail::equal_to, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_iterator<Rng>::type>::type find_end(ExPolicy &&policy, Rng &&rng, Rng2 &&rng2, Pred &&op = Pred(), Proj &&proj = Proj())

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.
  • Rng: 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<>
  • 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 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.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced iterator_t<Rng> and 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 = detail::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.

#include <hpx/parallel/container_algorithms/for_each.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

#include <hpx/parallel/container_algorithms/reverse.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

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

template <typename ExPolicy, typename Rng, typename OutIter>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_iterator<Rng>::type), tag::out(OutIter)>>::type reverse_copy(ExPolicy &&policy, Rng &&rng, OutIter 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.
  • 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.
  • dest_first: Refers to the begin of the destination range.

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

Return
The reverse_copy algorithm returns a hpx::future<tagged_pair<tag::in(BidirIter), tag::out(OutIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(BidirIter), tag::out(OutIter)> 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.

#include <hpx/parallel/container_algorithms/search.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng1, typename Rng2, typename Pred = detail::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 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 ExPolicy, typename Rng1, typename Rng2, typename Pred = detail::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 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.

#include <hpx/parallel/container_algorithms/fill.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename T>
util::detail::algorithm_result<ExPolicy>::type fill(ExPolicy &&policy, Rng &&rng, 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.
  • 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 Rng, typename Size, typename T>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_type>::type fill_n(ExPolicy &&policy, Rng &rng, 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.
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input 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.
  • rng: Refers to 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.

#include <hpx/parallel/container_algorithms/merge.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng1, typename Rng2, typename RandIter3, typename Comp = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(typename hpx::traits::range_iterator<Rng1>::type), tag::in2(typename hpx::traits::range_iterator<Rng2>::type), tag::out(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<tagged_tuple<tag::in1(RandIter1), tag::in2(RandIter2), tag::out(RandIter3)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_tuple<tag::in1(RandIter1), tag::in2(RandIter2), tag::out(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 Rng, typename RandIter, typename Comp = detail::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

#include <hpx/parallel/container_algorithms/remove.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

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

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

#include <hpx/parallel/container_algorithms/minmax.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/container_algorithms/transform.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename OutIter, typename F, 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(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 InIter 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<tagged_pair<tag::in(InIter), tag::out(OutIter)> > if the execution policy is of type parallel_task_policy and returns tagged_pair<tag::in(InIter), tag::out(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 Rng, typename InIter2, typename OutIter, typename F, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(typename hpx::traits::range_iterator<Rng>::type), tag::in2(InIter2), tag::out(OutIter)>>::type transform(ExPolicy &&policy, Rng &&rng, InIter2 first2, OutIter 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.
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.
  • InIter2: The type of the source iterators for the second range 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.
  • 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.
  • rng: Refers to the 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 InIter1 and InIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively. The type Ret must be such that an object of type OutIter 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<tagged_tuple<tag::in1(InIter1), tag::in2(InIter2), tag::out(OutIter)> > if the execution policy is of type parallel_task_policy and returns tagged_tuple<tag::in1(InIter1), tag::in2(InIter2), tag::out(OutIter)> 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.

template <typename ExPolicy, typename Rng1, typename Rng2, typename OutIter, typename F, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(typename hpx::traits::range_iterator<Rng1>::type), tag::in2(typename hpx::traits::range_iterator<Rng2>::type), tag::out(OutIter)>>::type transform(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, OutIter dest, F &&f, Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())

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 min(last2-first2, last1-first1) 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.
  • Rng1: The type of the first source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.
  • Rng2: The type of the second 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.
  • 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.
  • 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.
  • 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 InIter1 and InIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively. The type Ret must be such that an object of type OutIter 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.

Note
The algorithm will invoke the binary predicate until it reaches the end of the shorter of the two given input sequences
Return
The transform algorithm returns a hpx::future<tagged_tuple<tag::in1(InIter1), tag::in2(InIter2), tag::out(OutIter)> > if the execution policy is of type parallel_task_policy and returns tagged_tuple<tag::in1(InIter1), tag::in2(InIter2), tag::out(OutIter)> otherwise. The transform algorithm returns a tuple holding an iterator referring to the first element r 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.

#include <hpx/parallel/container_algorithms/unique.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/container_algorithms/replace.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename T1, typename T2, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_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 [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.
  • 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 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 ExPolicy, typename Rng, typename F, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename hpx::traits::range_traits<Rng>::iterator_type>::type replace_if(ExPolicy &&policy, Rng &&rng, F &&f, T const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria (for which predicate f returns true) with new_value in the range [first, last).

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

Note
Complexity: Performs exactly last - first 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.
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a forward iterator.
  • F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires F to meet the requirements of CopyConstructible. (deduced).
  • T: The type of the new values to replace (deduced).
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • 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 elements which need to replaced. The signature of this predicate should be equivalent to:
    bool pred(const Type &a);
    

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

    Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.
  • new_value: Refers to the new value to use as the replacement.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

Return
The replace_if algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise. It returns last.

template <typename ExPolicy, typename Rng, typename OutIter, typename T1, typename T2, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_traits<Rng>::iterator_type), tag::out(OutIter)>>::type replace_copy(ExPolicy &&policy, Rng &&rng, OutIter dest, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, last) to another range beginning at dest replacing all elements satisfying a specific criteria with new_value.

Effects: Assigns to every iterator it in the range [result, result + (last - first)) either new_value or *(first + (it - result)) depending on whether the following corresponding condition holds: INVOKE(proj, *(first + (i - result))) == old_value

The assignments in the parallel

replace_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first applications of the predicate.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • 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
  • 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<tagged_pair<tag::in(InIter), tag::out(OutIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(InIter), tag::out(OutIter)> 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 OutIter, typename F, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_traits<Rng>::iterator_type), tag::out(OutIter)>>::type replace_copy_if(ExPolicy &&policy, Rng &&rng, OutIter dest, F &&f, T const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, last) to another range beginning at dest replacing all elements satisfying a specific criteria with new_value.

Effects: Assigns to every iterator it in the range [result, result + (last - first)) either new_value or *(first + (it - result)) depending on whether the following corresponding condition holds: INVOKE(f, INVOKE(proj, *(first + (i - result)))) != false

The assignments in the parallel

replace_copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first applications of the predicate.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • 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 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.
  • dest: Refers to the beginning of the destination range.
  • f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the elements which need to replaced. The signature of this predicate should be equivalent to:
    bool pred(const Type &a);
    

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

    Type must be such that an object of type 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 a hpx::future<tagged_pair<tag::in(InIter), tag::out(OutIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(InIter), tag::out(OutIter)> otherwise. The replace_copy_if algorithm returns the input iterator last and the output iterator to the element in the destination range, one past the last element copied.

#include <hpx/parallel/container_algorithms/move.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename OutIter>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_traits<Rng>::iterator_type), tag::out(OutIter)>>::type move(ExPolicy &&policy, Rng &&rng, OutIter 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.
  • 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.
  • 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<tagged_pair<tag::in(iterator_t<Rng>), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(iterator_t<Rng>), 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.

#include <hpx/parallel/container_algorithms/copy.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename OutIter>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_traits<Rng>::iterator_type), tag::out(OutIter)>>::type copy(ExPolicy &&policy, Rng &&rng, OutIter 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.
  • 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.
  • 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<tagged_pair<tag::in(iterator_t<Rng>), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(iterator_t<Rng>), tag::out(FwdIter2)> otherwise. The copy algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.

template <typename ExPolicy, typename Rng, typename OutIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_traits<Rng>::iterator_type), tag::out(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<tagged_pair<tag::in(iterator_t<Rng>), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(iterator_t<Rng>), tag::out(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.

#include <hpx/parallel/container_algorithms/generate.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/container_algorithms/is_heap.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

#include <hpx/parallel/container_algorithms/remove_copy.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename OutIter, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_traits<Rng>::iterator_type), tag::out(OutIter)>>::type remove_copy(ExPolicy &&policy, Rng &&rng, OutIter dest, T const &val, Proj &&proj = Proj())

Copies the elements in the range, defined by [first, last), to another range beginning at dest. Copies only the elements for which the comparison operator returns false when compare to val. The order of the elements that are not removed is preserved.

Effects: Copies all the elements referred to by the iterator it in the range [first,last) for which the following corresponding conditions do not hold: INVOKE(proj, *it) == value

The assignments in the parallel

remove_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • 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.
  • T: The type that the result of dereferencing InIter is compared to.
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • rng: Refers to the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.
  • val: Value to be removed.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

Return
The remove_copy algorithm returns a hpx::future<tagged_pair<tag::in(InIter), tag::out(OutIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(InIter), tag::out(OutIter)> 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 Rng, typename OutIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(typename hpx::traits::range_traits<Rng>::iterator_type), tag::out(OutIter)>>::type remove_copy_if(ExPolicy &&policy, Rng &&rng, OutIter dest, F &&f, Proj &&proj = Proj())

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

Effects: Copies all the elements referred to by the iterator it in the range [first,last) for which the following corresponding conditions do not hold: INVOKE(pred, INVOKE(proj, *it)) != false.

The assignments in the parallel

remove_copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • 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 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.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

Return
The remove_copy_if algorithm returns a hpx::future<tagged_pair<tag::in(InIter), tag::out(OutIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(InIter), tag::out(OutIter)> 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.

#include <hpx/parallel/container_algorithms/sort.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename Rng, typename Proj = util::projection_identity, typename Compare = detail::less>
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.

#include <hpx/parallel/container_algorithms/count.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/util/partitioner_with_cleanup.hpp>

#include <hpx/parallel/util/transfer.hpp>

namespace hpx
namespace parallel
namespace util

Functions

template <typename InIter, typename OutIter>
std::pair<InIter, OutIter> copy(InIter first, InIter last, OutIter dest)
template <typename InIter, typename OutIter>
HPX_HOST_DEVICE std::pair<InIter, OutIter> hpx::parallel::util::copy_n(InIter first, std::size_t count, OutIter dest)
template <typename InIter, typename OutIter>
void copy_synchronize(InIter const &first, OutIter const &dest)
template <typename InIter, typename OutIter>
std::pair<InIter, OutIter> move(InIter first, InIter last, OutIter dest)
template <typename InIter, typename OutIter>
std::pair<InIter, OutIter> move_n(InIter first, std::size_t count, OutIter dest)

#include <hpx/parallel/util/scan_partitioner.hpp>

#include <hpx/parallel/util/projection_identity.hpp>

namespace hpx
namespace parallel
namespace util
struct projection_identity

Public Functions

template <typename T>
HPX_HOST_DEVICE T&& hpx::parallel::util::projection_identity::operator()(T && val) const

#include <hpx/parallel/util/invoke_projected.hpp>

namespace hpx
namespace parallel
namespace util
template <typename Pred, typename Proj>
struct invoke_projected

Public Types

typedef hpx::util::decay<Pred>::type pred_type
typedef hpx::util::decay<Proj>::type proj_type

Public Functions

template <typename Pred_, typename Proj_>
invoke_projected(Pred_ &&pred, Proj_ &&proj)
template <typename T>
auto operator()(T &&t)

Public Members

pred_type pred_
proj_type proj_

#include <hpx/parallel/util/cancellation_token.hpp>

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_

#include <hpx/parallel/util/foreach_partitioner.hpp>

#include <hpx/parallel/util/loop.hpp>

namespace hpx
namespace parallel
namespace util

Functions

template <typename ExPolicy, typename VecOnly, typename F, typename… Iters>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, typename hpx::util::invoke_result<F, Iters...>::type>::type hpx::parallel::util::loop_step(VecOnly, F && f, Iters &... its)
template <typename ExPolicy, typename Iter>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, bool>::type hpx::parallel::util::loop_optimization(Iter, Iter)
template <typename ExPolicy, typename Begin, typename End, typename F>
HPX_HOST_DEVICE Begin hpx::parallel::util::loop(ExPolicy &&, Begin begin, End end, F && f)
template <typename ExPolicy, typename Begin, typename End, typename CancelToken, typename F>
HPX_HOST_DEVICE Begin hpx::parallel::util::loop(ExPolicy &&, Begin begin, End end, CancelToken & tok, F && f)
template <typename ExPolicy, typename VecOnly, typename Begin1, typename End1, typename Begin2, typename F>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, std::pair<Begin1, Begin2> >::type hpx::parallel::util::loop2(VecOnly, Begin1 begin1, End1 end1, Begin2 begin2, F && f)
template <typename ExPolicy, typename Iter, typename F>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, Iter>::type hpx::parallel::util::loop_n(Iter it, std::size_t count, F && f)
template <typename ExPolicy, typename Iter, typename CancelToken, typename F>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, Iter>::type hpx::parallel::util::loop_n(Iter it, std::size_t count, CancelToken & tok, F && f)
template <typename Iter, typename F, typename Cleanup>
Iter loop_with_cleanup(Iter it, Iter last, F &&f, Cleanup &&cleanup)
template <typename Iter, typename FwdIter, typename F, typename Cleanup>
FwdIter loop_with_cleanup(Iter it, Iter last, FwdIter dest, F &&f, Cleanup &&cleanup)
template <typename Iter, typename F, typename Cleanup>
Iter loop_with_cleanup_n(Iter it, std::size_t count, F &&f, Cleanup &&cleanup)
template <typename Iter, typename FwdIter, typename F, typename Cleanup>
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>
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>
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>
Iter loop_idx_n(std::size_t base_idx, Iter it, std::size_t count, F &&f)
template <typename Iter, typename CancelToken, typename F>
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)

#include <hpx/parallel/util/prefetching.hpp>

namespace hpx
namespace parallel
namespace util

Functions

template <typename Itr, typename... Ts>
detail::prefetcher_context<Itr, Ts const...> make_prefetcher_context(Itr base_begin, Itr base_end, std::size_t p_factor, Ts const&... rngs)

#include <hpx/parallel/util/partitioner.hpp>

#include <hpx/parallel/util/zip_iterator.hpp>

#include <hpx/parallel/util/compare_projected.hpp>

namespace hpx
namespace parallel
namespace util
template <typename Compare, typename Proj>
template<>
struct compare_projected<Compare, Proj>

Public Functions

template <typename Compare_, typename Proj_>
compare_projected(Compare_ &&comp, Proj_ &&proj)
template <typename T1, typename T2>
bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj proj_
template <typename Compare, typename Proj1, typename Proj2>
template<>
struct compare_projected<Compare, Proj1, Proj2>

Public Functions

template <typename Compare_, typename Proj1_, typename Proj2_>
compare_projected(Compare_ &&comp, Proj1_ &&proj1, Proj2_ &&proj2)
template <typename T1, typename T2>
bool operator()(T1 &&t1, T2 &&t2) const

Public Members

Compare comp_
Proj1 proj1_
Proj2 proj2_

#include <hpx/parallel/util/transform_loop.hpp>

namespace hpx
namespace parallel
namespace util

Functions

template <typename ExPolicy, typename Iter, typename OutIter, typename F>
HPX_HOST_DEVICE std::pair<Iter, OutIter> hpx::parallel::util::transform_loop(ExPolicy &&, Iter it, Iter end, OutIter dest, F && f)
template <typename ExPolicy, typename InIter1, typename InIter2, typename OutIter, typename F>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, hpx::util::tuple<InIter1, InIter2, OutIter> >::type hpx::parallel::util::transform_binary_loop(InIter1 first1, InIter1 last1, InIter2 first2, OutIter dest, F && f)
template <typename ExPolicy, typename InIter1, typename InIter2, typename OutIter, typename F>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, hpx::util::tuple<InIter1, InIter2, OutIter> >::type hpx::parallel::util::transform_binary_loop(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter dest, F && f)
template <typename ExPolicy, typename Iter, typename OutIter, typename F>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, std::pair<Iter, OutIter> >::type hpx::parallel::util::transform_loop_n(Iter it, std::size_t count, OutIter dest, F && f)
template <typename ExPolicy, typename InIter1, typename InIter2, typename OutIter, typename F>
HPX_HOST_DEVICE std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, hpx::util::tuple<InIter1, InIter2, OutIter> >::type hpx::parallel::util::transform_binary_loop_n(InIter1 first1, std::size_t count, InIter2 first2, OutIter dest, F && f)

#include <hpx/parallel/algorithms/reduce.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIterB, typename FwdIterE, typename T, typename F>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, T>::type>::type reduce(ExPolicy &&policy, FwdIterB first, FwdIterE 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.
  • 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.
  • 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 FwdIterB, typename FwdIterE, typename T>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, T>::type>::type reduce(ExPolicy &&policy, FwdIterB first, FwdIterE 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.
  • 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 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 FwdIterB, typename FwdIterE>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<FwdIterB>::value_type>::type>::type reduce(ExPolicy &&policy, FwdIterB first, FwdIterE 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.
  • 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.
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.

#include <hpx/parallel/algorithms/partition.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/rotate.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::begin(FwdIter), tag::end(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, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(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.

#include <hpx/parallel/algorithms/all_any_none.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/find.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter, typename T>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter>::type>::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>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter>::type>::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>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter>::type>::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, typename Proj = util::projection_identity>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter1>::type>::type find_end(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred(), Proj &&proj = Proj())

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, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter1>::type>::type find_first_of(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 s_first, FwdIter2 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 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.

#include <hpx/parallel/algorithms/for_each.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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.

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

template <typename ExPolicy, typename FwdIter, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type for_each(ExPolicy &&policy, FwdIter first, FwdIter 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.

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

#include <hpx/parallel/algorithms/reverse.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

Reverses the order of the elements in the range [first, last). Behaves as if applying std::iter_swap to every pair of iterators first+i, (last-i) - 1 for each non-negative i < (last-first)/2.

The assignments in the parallel

reverse algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Linear in the distance between first and last.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • BidirIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an bidirectional iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.

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

Return
The reverse algorithm returns a hpx::future<BidirIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns BidirIter otherwise. It returns last.

template <typename ExPolicy, typename BidirIter, typename FwdIter>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(BidirIter), tag::out(FwdIter)>>::type reverse_copy(ExPolicy &&policy, BidirIter first, BidirIter last, FwdIter dest_first)

Copies the elements from the range [first, last) to another range beginning at dest_first in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(dest_first + (last - first) - 1 - i) = *(first + i) once for each non-negative i < (last - first) If the source and destination ranges (that is, [first, last) and [dest_first, dest_first+(last-first)) respectively) overlap, the behavior is undefined.

The assignments in the parallel

reverse_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first assignments.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • BidirIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an bidirectional iterator.
  • FwdIter: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest_first: Refers to the begin of the destination range.

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

Return
The reverse_copy algorithm returns a hpx::future<tagged_pair<tag::in(BidirIter), tag::out(FwdIter)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(BidirIter), tag::out(FwdIter)> otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

#include <hpx/parallel/algorithms/is_partitioned.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter, typename Pred>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::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.
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_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.

#include <hpx/parallel/algorithms/transform_reduce_binary.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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.

#include <hpx/parallel/algorithms/uninitialized_value_construct.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

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

The assignments in the parallel

uninitialized_value_construct algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first assignments.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.

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

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

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

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

The assignments in the parallel

uninitialized_value_construct_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • Size: The type of the argument specifying the number of elements to apply f to.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • count: Refers to the number of elements starting at first the algorithm will be applied to.

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

Return
The uninitialized_value_construct_n algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The uninitialized_value_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

#include <hpx/parallel/algorithms/uninitialized_move.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

Moves the elements in the range, defined by [first, last), to an uninitialized memory area beginning at dest. If an exception is thrown during the initialization, some objects in [first, last) are left in a valid but unspecified state.

The assignments in the parallel

uninitialized_move algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first move operations.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.

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

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

template <typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type uninitialized_move_n(ExPolicy &&policy, FwdIter1 first, Size count, FwdIter2 dest)

Moves the elements in the range [first, first + count), starting from first and proceeding to first + count - 1., to another range beginning at dest. If an exception is thrown during the initialization, some objects in [first, first + count) are left in a valid but unspecified state.

The assignments in the parallel

uninitialized_move_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly count movements, if count > 0, no move operations otherwise.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • Size: The type of the argument specifying the number of elements to apply f to.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • count: Refers to the number of elements starting at first the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.

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

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

#include <hpx/parallel/algorithms/search.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter, typename FwdIter2, typename Pred = detail::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type search(ExPolicy &&policy, FwdIter first, FwdIter last, FwdIter2 s_first, FwdIter2 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 input 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<>
  • 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 ExPolicy, typename FwdIter, typename FwdIter2, typename Pred = detail::equal_to, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
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(), 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 input 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
  • 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.

#include <hpx/parallel/algorithms/is_sorted.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter, typename Pred = detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::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 ExPolicy, typename FwdIter, typename Pred = detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter>::type>::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.

#include <hpx/parallel/algorithms/reduce_by_key.hpp>

namespace hpx
namespace parallel
namespace v1

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, std::pair<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.

#include <hpx/parallel/algorithms/fill.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/transform_inclusive_scan.hpp>

namespace hpx
namespace parallel
namespace v1

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

#include <hpx/parallel/algorithms/adjacent_find.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

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

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

#include <hpx/parallel/algorithms/set_intersection.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter3>::type>::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.

#include <hpx/parallel/algorithms/sort_by_key.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/swap_ranges.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2>
std::enable_if<execution::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.

#include <hpx/parallel/algorithms/uninitialized_default_construct.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

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

The assignments in the parallel

uninitialized_default_construct algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first assignments.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.

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

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

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

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

The assignments in the parallel

uninitialized_default_construct_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • Size: The type of the argument specifying the number of elements to apply f to.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • count: Refers to the number of elements starting at first the algorithm will be applied to.

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

Return
The uninitialized_default_construct_n algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The uninitialized_default_construct_n algorithm returns the iterator to the element in the source range, one past the last element constructed.

#include <hpx/parallel/algorithms/merge.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename RandIter1, typename RandIter2, typename RandIter3, typename Comp = detail::less, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(RandIter1), tag::in2(RandIter2), tag::out(RandIter3)>>::type merge(ExPolicy &&policy, RandIter1 first1, RandIter1 last1, RandIter2 first2, RandIter2 last2, 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.
  • 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<>
  • 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 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
  • 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<tagged_tuple<tag::in1(RandIter1), tag::in2(RandIter2), tag::out(RandIter3)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_tuple<tag::in1(RandIter1), tag::in2(RandIter2), tag::out(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 RandIter, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, RandIter>::type inplace_merge(ExPolicy &&policy, RandIter first, RandIter middle, RandIter 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.
  • 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.
  • 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<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

#include <hpx/parallel/algorithms/remove.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

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

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

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

#include <hpx/parallel/algorithms/set_union.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename 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.

#include <hpx/parallel/algorithms/minmax.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/set_difference.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename 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.

#include <hpx/parallel/algorithms/for_loop.hpp>

namespace hpx
namespace parallel
namespace v2

Functions

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

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

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it applies user-provided function objects.
  • I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.
  • Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:
    <ignored> pred(I const& a, ...);
    

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

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

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

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

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note
As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.
Note
The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

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

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

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

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

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

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

The execution of for_loop without specifying an execution policy is equivalent to specifying parallel::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 S, typename... Args, &&std::is_integral< S >::value>
util::detail::algorithm_result<ExPolicy>::type for_loop_strided(ExPolicy &&policy, typename std::decay<I>::type first, I last, S stride, Args&&... args)

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

Requires:

I shall be an integral type or meet the requirements of an input iterator type. The args parameter pack shall have at least one element, comprising objects returned by invocations of reduction and/or induction function templates followed by exactly one element invocable element-access function, f. f shall meet the requirements of MoveConstructible.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it applies user-provided function objects.
  • I: The type of the iteration variable. This could be an (forward) iterator type or an integral type.
  • S: The type of the stride variable. This should be an integral type.
  • Args: A parameter pack, it’s last element is a function object to be invoked for each iteration, the others have to be either conforming to the induction or reduction concept.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • stride: Refers to the stride of the iteration steps. This shall have non-zero value and shall be negative only if I has integral type or meets the requirements of a bidirectional iterator.
  • args: The last element of this parameter pack is the function (object) to invoke, while the remaining elements of the parameter pack are instances of either induction or reduction objects. The function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last) should expose a signature equivalent to:
    <ignored> pred(I const& a, ...);
    

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

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

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

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

args parameter pack excluding f, an additional argument is passed to each application of f as follows:
Note
As described in the C++ standard, arithmetic on non-random-access iterators is performed using advance and distance.
Note
The order of the elements of the input sequence is important for determining ordinal position of an application of f, even though the applications themselves may be unordered.

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

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

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

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

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

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

The execution of for_loop without specifying an execution policy is equivalent to specifying parallel::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 Size, typename... Args, &&std::is_integral< Size >::value>
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 sequenced_task_policy or parallel_task_policy and returns void otherwise.

template <typename I, typename Size, typename... Args, &&std::is_integral< Size >::value>
void for_loop_n(I first, Size size, 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 parallel::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 S, typename... Args, &&std::is_integral< Size >::value &&std::is_integral< S >::value>
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 sequenced_task_policy or parallel_task_policy and returns void otherwise.

template <typename I, typename Size, typename S, typename... Args, &&std::is_integral< Size >::value &&std::is_integral< S >::value>
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 parallel::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.

#include <hpx/parallel/algorithms/transform.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type transform(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F &&f, Proj &&proj = Proj())

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.
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.
  • f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate. 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 FwdIter 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<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 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, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(FwdIter3)>>::type transform(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, 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 [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.
  • 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.
  • 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<tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(FwdIter3)> > if the execution policy is of type parallel_task_policy and returns tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(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.

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename F, typename Proj1 = util::projection_identity, typename Proj2 = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(FwdIter3)>>::type transform(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 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 [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 min(last2-first2, last1-first1) 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.
  • 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.

Note
The algorithm will invoke the binary predicate until it reaches the end of the shorter of the two given input sequences
Return
The transform algorithm returns a hpx::future<tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(FwdIter3)> > if the execution policy is of type parallel_task_policy and returns tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(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.

#include <hpx/parallel/algorithms/unique.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/for_loop_reduction.hpp>

namespace hpx
namespace parallel
namespace v2

Functions

template <typename T, typename Op>
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.

#include <hpx/parallel/algorithms/replace.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter, typename T1, typename T2, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::type replace(ExPolicy &&policy, FwdIter first, FwdIter last, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Replaces all elements satisfying specific criteria with new_value in the range [first, last).

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

The assignments in the parallel

replace algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first assignments.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.
  • T1: The type of the old value to replace (deduced).
  • T2: The type of the new values to replace (deduced).
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • old_value: Refers to the old value of the elements to replace.
  • new_value: Refers to the new value to use as the replacement.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

Return
The replace algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise. It returns last.

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

Replaces all elements satisfying specific criteria (for which predicate f returns true) with new_value in the range [first, last).

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

The assignments in the parallel

replace_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first applications of the predicate.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.
  • F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires F to meet the requirements of CopyConstructible. (deduced).
  • T: The type of the new values to replace (deduced).
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the elements which need to replaced. The signature of this predicate should be equivalent to:
    bool pred(const Type &a);
    

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

    Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.
  • new_value: Refers to the new value to use as the replacement.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

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

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T1, typename T2, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type replace_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T1 const &old_value, T2 const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, last) to another range beginning at dest replacing all elements satisfying a specific criteria with new_value.

Effects: Assigns to every iterator it in the range [result, result + (last - first)) either new_value or *(first + (it - result)) depending on whether the following corresponding condition holds: INVOKE(proj, *(first + (i - result))) == old_value

The assignments in the parallel

replace_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first applications of the predicate.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
  • T1: The type of the old value to replace (deduced).
  • T2: The type of the new values to replace (deduced).
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.
  • old_value: Refers to the old value of the elements to replace.
  • new_value: Refers to the new value to use as the replacement.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

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

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type replace_copy_if(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F &&f, T const &new_value, Proj &&proj = Proj())

Copies the all elements from the range [first, last) to another range beginning at dest replacing all elements satisfying a specific criteria with new_value.

Effects: Assigns to every iterator it in the range [result, result + (last - first)) either new_value or *(first + (it - result)) depending on whether the following corresponding condition holds: INVOKE(f, INVOKE(proj, *(first + (i - result)))) != false

The assignments in the parallel

replace_copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first applications of the predicate.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
  • F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of equal requires F to meet the requirements of CopyConstructible. (deduced).
  • T: The type of the new values to replace (deduced).
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.
  • f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the elements which need to replaced. The signature of this predicate should be equivalent to:
    bool pred(const Type &a);
    

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

    Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.
  • new_value: Refers to the new value to use as the replacement.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

Return
The replace_copy_if algorithm returns a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The replace_copy_if algorithm returns the input iterator last and the output iterator to the element in the destination range, one past the last element copied.

#include <hpx/parallel/algorithms/lexicographical_compare.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

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

The comparison operations in the parallel

lexicographical_compare algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: At most 2 * min(N1, N2) applications of the comparison operation, where N1 = std::distance(first1, last) and N2 = std::distance(first2, last2).
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.
  • FwdIter2: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.
  • Pred: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of lexicographical_compare requires Pred to meet the requirements of CopyConstructible. This defaults to std::less<>
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first1: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.
  • last1: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.
  • first2: Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.
  • last2: Refers to the end of the sequence of elements of the second range the algorithm will be applied to.
  • pred: Refers to the comparison function that the first and second ranges will be applied to

The comparison operations in the parallel lexicographical_compare algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Note
Lexicographical comparison is an operation with the following properties
  • Two ranges are compared element by element
  • The first mismatching element defines which range is lexicographically less or greater than the other
  • If one range is a prefix of another, the shorter range is lexicographically less than the other
  • If two ranges have equivalent elements and are of the same length, then the ranges are lexicographically equal
  • An empty range is lexicographically less than any non-empty range
  • Two empty ranges are lexicographically equal
Return
The lexicographically_compare algorithm returns a hpx::future<bool> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns bool otherwise. The lexicographically_compare algorithm returns true if the first range is lexicographically less, otherwise it returns false. range [first2, last2), it returns false.

#include <hpx/parallel/algorithms/uninitialized_fill.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter, typename T>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy>::type>::type uninitialized_fill(ExPolicy &&policy, FwdIter first, FwdIter last, T const &value)

Copies the given value to an uninitialized memory area, defined by the range [first, last). If an exception is thrown during the initialization, the function has no effects.

The initializations in the parallel

uninitialized_fill algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Linear in the distance between first and last
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • T: The type of the value to be assigned (deduced).
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • value: The value to be assigned.

The initializations in the parallel uninitialized_fill algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

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

template <typename ExPolicy, typename FwdIter, typename Size, typename T>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy>::type>::type uninitialized_fill_n(ExPolicy &&policy, FwdIter first, Size count, T const &value)

Copies the given value value to the first count elements in an uninitialized memory area beginning at first. If an exception is thrown during the initialization, the function has no effects.

The initializations in the parallel

uninitialized_fill_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter: The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.
  • Size: The type of the argument specifying the number of elements to apply f to.
  • T: The type of the value to be assigned (deduced).
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • count: Refers to the number of elements starting at first the algorithm will be applied to.
  • value: The value to be assigned.

The initializations in the parallel uninitialized_fill_n algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

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

#include <hpx/parallel/algorithms/includes.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename 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.

#include <hpx/parallel/algorithms/exclusive_scan.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T, typename Op>
std::enable_if<execution::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 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 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<execution::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 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 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.

#include <hpx/parallel/algorithms/move.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(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.

#include <hpx/parallel/algorithms/copy.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(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<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The copy algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.

template <typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(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<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type copy_if(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F &&f, Proj &&proj = Proj())

Copies the elements in the range, defined by [first, last), to another range beginning at dest. Copies only the elements for which the predicate f returns 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.
  • F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.
  • f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the 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.
  • 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<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.

#include <hpx/parallel/algorithms/for_loop_induction.hpp>

namespace hpx
namespace parallel
namespace v2

Functions

template <typename T>
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)

#include <hpx/parallel/algorithms/uninitialized_copy.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

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

Copies the elements in the range, defined by [first, last), to an uninitialized memory area beginning at dest. If an exception is thrown during the copy operation, the function has no effects.

The assignments in the parallel

uninitialized_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first assignments.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.

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

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

template <typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::type uninitialized_copy_n(ExPolicy &&policy, FwdIter1 first, Size count, FwdIter2 dest)

Copies the elements in the range [first, first + count), starting from first and proceeding to first + count - 1., to another range beginning at dest. If an exception is thrown during the copy operation, the function has no effects.

The assignments in the parallel

uninitialized_copy_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.
  • Size: The type of the argument specifying the number of elements to apply f to.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • count: Refers to the number of elements starting at first the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.

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

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

#include <hpx/parallel/algorithms/generate.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/inclusive_scan.hpp>

namespace hpx
namespace parallel
namespace v1

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

#include <hpx/parallel/algorithms/mismatch.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, std::pair<FwdIter1, FwdIter2>>::type>::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>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, std::pair<FwdIter1, FwdIter2>>::type>::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).

#include <hpx/parallel/algorithms/set_symmetric_difference.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename FwdIter3, typename Pred = detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename 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.

#include <hpx/parallel/algorithms/is_heap.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename RandIter, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::type is_heap(ExPolicy &&policy, RandIter first, RandIter 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.
  • 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).
  • 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 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 RandIter, typename Comp = detail::less, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, RandIter>::type is_heap_until(ExPolicy &&policy, RandIter first, RandIter last, 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.
  • 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).
  • 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 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.

#include <hpx/parallel/algorithms/equal.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::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>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::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.

#include <hpx/parallel/algorithms/remove_copy.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename T, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type remove_copy(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T const &val, Proj &&proj = Proj())

Copies the elements in the range, defined by [first, last), to another range beginning at dest. Copies only the elements for which the comparison operator returns false when compare to val. The order of the elements that are not removed is preserved.

Effects: Copies all the elements referred to by the iterator it in the range [first,last) for which the following corresponding conditions do not hold: INVOKE(proj, *it) == value

The assignments in the parallel

remove_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
  • T: The type that the result of dereferencing FwdIter1 is compared to.
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.
  • val: Value to be removed.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

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

template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::type remove_copy_if(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F &&f, Proj &&proj = Proj())

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

Effects: Copies all the elements referred to by the iterator it in the range [first,last) for which the following corresponding conditions do not hold: INVOKE(pred, INVOKE(proj, *it)) != false.

The assignments in the parallel

remove_copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
Note
Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.
Template Parameters
  • ExPolicy: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
  • FwdIter1: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
  • FwdIter2: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
  • F: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.
  • Proj: The type of an optional projection function. This defaults to util::projection_identity
Parameters
  • policy: The execution policy to use for the scheduling of the iterations.
  • first: Refers to the beginning of the sequence of elements the algorithm will be applied to.
  • last: Refers to the end of the sequence of elements the algorithm will be applied to.
  • dest: Refers to the beginning of the destination range.
  • f: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the elements to be removed. The signature of this predicate should be equivalent to:
    bool pred(const Type &a);
    

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

    Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.
  • proj: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

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

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

#include <hpx/parallel/algorithms/destroy.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/adjacent_difference.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename FwdIter1, typename FwdIter2>
std::enable_if<execution::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<execution::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.

#include <hpx/parallel/algorithms/transform_exclusive_scan.hpp>

namespace hpx
namespace parallel
namespace v1

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

#include <hpx/parallel/algorithms/transform_reduce.hpp>

namespace hpx
namespace parallel
namespace v1

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.

#include <hpx/parallel/algorithms/sort.hpp>

namespace hpx
namespace parallel
namespace v1

Functions

template <typename ExPolicy, typename RandomIt, typename Proj = util::projection_identity, typename Compare = detail::less>
util::detail::algorithm_result<ExPolicy, RandomIt>::type sort(ExPolicy &&policy, RandomIt first, RandomIt last, Compare &&comp = Compare(), 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.

#include <hpx/parallel/algorithms/count.hpp>

namespace hpx
namespace parallel
namespace v1

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 FwdIterB, typename FwdIterE, typename F, typename Proj = util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<FwdIterB>::difference_type>::type count_if(ExPolicy &&policy, FwdIterB first, FwdIterE 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.
  • 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.
  • 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.

#include <hpx/parallel/traits/projected.hpp>

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

Public Types

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

Public Types

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

Public Types

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

Public Types

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

Public Types

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

Public Types

typedef segmented_iterator_traits<Iterator>::local_iterator local_iterator
typedef segmented_local_iterator_traits<local_iterator>::local_raw_iterator type

#include <hpx/parallel/traits/projected_range.hpp>

template <typename Proj, typename Rng>
template<>
struct projected_range<Proj, Rng, typename std::enable_if<hpx::traits::is_range<Rng>::value>::type>

Public Types

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

Public Types

typedef hpx::util::decay<Proj>::type projector_type
typedef hpx::traits::range_iterator<Rng>::type iterator_type

#include <hpx/parallel/datapar/iterator_helpers.hpp>

#include <hpx/parallel/datapar/loop.hpp>

#include <hpx/parallel/datapar/zip_iterator.hpp>

#include <hpx/parallel/datapar/transform_loop.hpp>