algorithms¶
The contents of this module can be included with the header
hpx/modules/algorithms.hpp
. These headers may be used by user-code but are not
guaranteed stable (neither header location nor contents). You are using these at
your own risk. If you wish to use non-public functionality from a module we
strongly suggest only including the module header hpx/modules/algorithms.hpp
, not
the particular header in which the functionality you would like to use is
defined. See Public API for a list of names that are part of the public
HPX API.
Header hpx/algorithms/traits/is_value_proxy.hpp
¶
Header hpx/algorithms/traits/projected.hpp
¶
-
template<typename
Iterator
>
structprojected_iterator
<Iterator, typename std::enable_if<is_segmented_iterator<Iterator>::value>::type>¶ - #include <projected.hpp>
Public Types
-
typedef segmented_iterator_traits<Iterator>::local_iterator
local_iterator
¶
-
typedef segmented_local_iterator_traits<local_iterator>::local_raw_iterator
type
¶
-
typedef segmented_iterator_traits<Iterator>::local_iterator
-
template<typename
Iterator
>
structprojected_iterator
<Iterator, typename hpx::util::always_void<typename hpx::util::decay<Iterator>::type::proxy_type>::type>¶ - #include <projected.hpp>
-
namespace
hpx
-
namespace
parallel
¶
-
namespace
traits
-
template<typename
T
, typenameEnable
= void>
structprojected_iterator
¶ - #include <projected.hpp>
-
template<typename
Iterator
>
structprojected_iterator
<Iterator, typename hpx::util::always_void<typename hpx::util::decay<Iterator>::type::proxy_type>::type> - #include <projected.hpp>
-
template<typename
Iterator
>
structprojected_iterator
<Iterator, typename std::enable_if<is_segmented_iterator<Iterator>::value>::type> - #include <projected.hpp>
Public Types
-
typedef segmented_iterator_traits<Iterator>::local_iterator
local_iterator
-
typedef segmented_local_iterator_traits<local_iterator>::local_raw_iterator
type
-
typedef segmented_iterator_traits<Iterator>::local_iterator
-
template<typename
-
namespace
Header hpx/algorithms/traits/projected_range.hpp
¶
Header hpx/algorithms/traits/segmented_iterator_traits.hpp
¶
-
namespace
hpx
-
namespace
traits
-
template<typename
Iterator
, typenameEnable
= void>
structsegmented_iterator_traits
¶ - #include <segmented_iterator_traits.hpp>
-
template<typename
Iterator
, typenameEnable
= void>
structsegmented_local_iterator_traits
¶ - #include <segmented_iterator_traits.hpp>
Public Types
-
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)¶
-
typedef Iterator
-
template<typename
-
namespace
Header hpx/parallel/algorithm.hpp
¶
Header hpx/parallel/algorithms/adjacent_difference.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
¶ Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeadjacent_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
, typenameFwdIter1
, typenameFwdIter2
, typenameOp
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeadjacent_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/adjacent_find.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenamePred
= detail::equal_to>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter>::type>::typeadjacent_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/all_any_none.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::typenone_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
, typenameFwdIter
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::typeany_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
, typenameFwdIter
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::typeall_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.
-
template<typename
Header hpx/parallel/algorithms/copy.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::typecopy
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)¶ Copies the elements in the range, defined by [first, last), to another range beginning at dest.
The assignments in the parallel
copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs exactly last - first assignments.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.
The assignments in the parallel copy algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy algorithm returns a hpx::future<FwdIter2> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2> otherwise. The copy algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameSize
, typenameFwdIter2
>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::typecopy_n
(ExPolicy &&policy, FwdIter1 first, Size count, FwdIter2 dest)¶ Copies the elements in the range [first, first + count), starting from first and proceeding to first + count - 1., to another range beginning at dest.
The assignments in the parallel
copy_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.Size
: The type of the argument specifying the number of elements to apply f to.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.count
: Refers to the number of elements starting at first the algorithm will be applied to.dest
: Refers to the beginning of the destination range.
The assignments in the parallel copy_n algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy_n algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameF
>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::typecopy_if
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Pred &&pred)¶ Copies the elements in the range, defined by [first, last), to another range beginning at dest. Copies only the elements for which the predicate f returns true. The order of the elements that are not removed is preserved.
The assignments in the parallel
copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.Pred
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.pred
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:bool pred(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.
The assignments in the parallel copy_if algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy_if algorithm returns a hpx::future<FwdIter2> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
Header hpx/parallel/algorithms/count.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIterB
, typenameFwdIterE
, typenameT
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<FwdIterB>::difference_type>::typecount
(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
, typenameIter
, typenameSent
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<Iter>::difference_type>::typecount_if
(ExPolicy &&policy, Iter first, Sent last, F &&f, Proj &&proj = Proj())¶ Returns the number of elements in the range [first, last) satisfying a specific criteria. This version counts elements for which predicate f returns true.
- Note
Complexity: Performs exactly last - first applications of the predicate.
- Note
The assignments in the parallel count_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
- Note
The assignments in the parallel count_if algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The count_if algorithm returns hpx::future<difference_type> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns difference_type otherwise (where difference_type is defined by std::iterator_traits<FwdIterB>::difference_type. The count algorithm returns the number of elements satisfying the given criteria.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the comparisons.Iter
: The type of the source begin iterator used (deduced). This iterator type must meet the requirements of an forward iterator.Sent
: The type of the source end iterator used (deduced). This iterator type must meet the requirements of an forward iterator.F
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of count_if requires F to meet the requirements of CopyConstructible.Proj
: The type of an optional projection function. This defaults to util::projection_identity
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:bool pred(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type FwdIterB can be dereferenced and then implicitly converted to Type.proj
: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.
-
template<typename
Header hpx/parallel/algorithms/destroy.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter
>
util::detail::algorithm_result<ExPolicy>::typedestroy
(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
, typenameFwdIter
, typenameSize
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typedestroy_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.
-
template<typename
Header hpx/parallel/algorithms/equal.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::equal_to>
util::detail::algorithm_result<ExPolicy, bool>::typeequal
(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
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::equal_to>
util::detail::algorithm_result<ExPolicy, bool>::typeequal
(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.
-
template<typename
Header hpx/parallel/algorithms/exclusive_scan.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameT
, typenameOp
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeexclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T init, Op &&op)¶ Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, *first, …, *(first + (i - result) - 1)).
The reduce operations in the parallel
exclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate op.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.T
: The type of the value to be used as initial (and intermediate) values (deduced).Op
: The type of the binary function object used for the reduction operation.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.init
: The initial value for the generalized sum.op
: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type1 &b);
The signature does not need to have const&, but the function must not modify the objects passed to it. The types
Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.
The reduce operations in the parallel exclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum. If op is not mathematically associative, the behavior of inclusive_scan may be non-deterministic.- Return
The exclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The exclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:
a1 when N is 1
op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameT
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeexclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T init)¶ Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(+, init, *first, …, *(first + (i - result) - 1))
The reduce operations in the parallel
exclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate std::plus<T>.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.T
: The type of the value to be used as initial (and intermediate) values (deduced).
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.init
: The initial value for the generalized sum.
The reduce operations in the parallel exclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum.- Return
The exclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The exclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aN) is defined as:
a1 when N is 1
GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aK)
GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, …, aN) where 1 < K+1 = M <= N.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/fill.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameT
>
util::detail::algorithm_result<ExPolicy>::typefill
(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
, typenameFwdIter
, typenameSize
, typenameT
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typefill_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.
-
template<typename
Header hpx/parallel/algorithms/find.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameT
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typefind
(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
, typenameFwdIter
, typenameF
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typefind_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
, typenameFwdIter
, typenameF
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typefind_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
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter1>::typefind_end
(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred())¶ Returns the last subsequence of elements [first2, last2) found in the range [first, last) using the given predicate f to compare elements.
The comparison operations in the parallel
find_end algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: at most S*(N-S+1) comparisons where S = distance(first2, last2) and N = distance(first1, last1).
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.Pred
: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of replace requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>Proj
: The type of an optional projection function. This defaults to util::projection_identity and is applied to the elements of type dereferenced FwdIter1 and dereferenced FwdIter2.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first1
: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.last1
: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.first2
: Refers to the beginning of the sequence of elements the algorithm will be searching for.last2
: Refers to the end of the sequence of elements of the algorithm will be searching for.op
: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:bool pred(const Type1 &a, const Type2 &b);
The signature does not need to have const &, but the function must not modify the objects passed to it. The types
Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively.proj
: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter1 and dereferenced FwdIter2 as a projection operation before the function f is invoked.
The comparison operations in the parallel find_end algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
This overload of
find_end is available if the user decides to provide the algorithm their own predicate f.- Return
The find_end algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The find_end algorithm returns an iterator to the beginning of the last subsequence [first2, last2) in range [first, last). If the length of the subsequence [first2, last2) is greater than the length of the range [first1, last1), last1 is returned. Additionally if the size of the subsequence is empty or no subsequence is found, last1 is also returned.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter1>::typefind_first_of
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 s_first, FwdIter2 s_last, Pred &&op = Pred())¶ Searches the range [first, last) for any elements in the range [s_first, s_last). Uses binary predicate p to compare elements
The comparison operations in the parallel
find_first_of algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = distance(first, last).
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the source iterators used for the second range (deduced). This iterator type must meet the requirements of an forward iterator.Pred
: The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of equal requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>Proj1
: The type of an optional projection function. This defaults to util::projection_identity and is applied to the elements of type dereferenced FwdIter1.Proj2
: The type of an optional projection function. This defaults to util::projection_identity and is applied to the elements of type dereferenced FwdIter2.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.last
: Refers to the end of the sequence of elements of the first range the algorithm will be applied to.s_first
: Refers to the beginning of the sequence of elements the algorithm will be searching for.s_last
: Refers to the end of the sequence of elements of the algorithm will be searching for.op
: The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:bool pred(const Type1 &a, const Type2 &b);
The signature does not need to have const &, but the function must not modify the objects passed to it. The types
Type1 and Type2 must be such that objects of types FwdIter1 and FwdIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively.proj1
: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter1 as a projection operation before the function op is invoked.proj2
: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter2 as a projection operation before the function op is invoked.
The comparison operations in the parallel find_first_of algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The find_first_of algorithm returns a hpx::future<FwdIter1> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter1 otherwise. The find_first_of algorithm returns an iterator to the first element in the range [first, last) that is equal to an element from the range [s_first, s_last). If the length of the subsequence [s_first, s_last) is greater than the length of the range [first, last), last is returned. Additionally if the size of the subsequence is empty or no subsequence is found, last is also returned. This overload of find_end is available if the user decides to provide the algorithm their own predicate f.
-
template<typename
Header hpx/parallel/algorithms/for_each.hpp
¶
-
namespace
hpx
Functions
-
template<typename
InIter
, typenameF
>
Ffor_each
(InIter first, InIter last, F &&f)¶ Applies f to the result of dereferencing every iterator in the range [first, last).
If
f returns a result, the result is ignored.- Note
Complexity: Applies f exactly last - first times.
If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.
- Return
f.
- Template Parameters
InIter
: The type of the source begin and end iterator used (deduced). This iterator type must meet the requirements of an input iterator.F
: The type of the function/function object to use (deduced). F must meet requirements of MoveConstructible.
- Parameters
first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:<ignored> pred(const Type &a);
The signature does not need to have const&. The type
Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.
-
template<typename
ExPolicy
, typenameFwdIter
, typenameF
>
util::detail::algorithm_result<ExPolicy, void>::typefor_each
(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)¶ Applies f to the result of dereferencing every iterator in the range [first, last).
If
f returns a result, the result is ignored.- Note
Complexity: Applies f exactly last - first times.
If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.
Unlike its sequential form, the parallel overload of for_each does not return a copy of its Function parameter, since parallelization may not permit efficient state accumulation.
The application of function objects in parallel algorithm invoked with an execution policy object of type
sequenced_policy execute in sequential order in the calling thread.- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it applies user-provided function objects.FwdIte
: The type of the source begin and end iterator used (deduced). This iterator type must meet the requirements of an forward iterator.F
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of for_each requires F to meet the requirements of CopyConstructible.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:<ignored> pred(const Type &a);
The signature does not need to have const&. The type
Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.
The application of function objects in parallel algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The for_each algorithm returns a hpx::future<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise.
-
template<typename
InIter
, typenameSize
, typenameF
>
InIterfor_each_n
(InIter first, Size count, F &&f)¶ Applies f to the result of dereferencing every iterator in the range [first, first + count), starting from first and proceeding to first + count - 1.
If
f returns a result, the result is ignored.- Note
Complexity: Applies f exactly count times.
If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.
- Return
first + count for non-negative values of count and first for negative values.
- Template Parameters
InIter
: The type of the source begin and end iterator used (deduced). This iterator type must meet the requirements of an input iterator.Size
: The type of the argument specifying the number of elements to apply f to.F
: The type of the function/function object to use (deduced). F must meet requirements of MoveConstructible.
- Parameters
first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.count
: Refers to the number of elements starting at first the algorithm will be applied to.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:<ignored> pred(const Type &a);
The signature does not need to have const&. The type
Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.
-
template<typename
ExPolicy
, typenameFwdIter
, typenameSize
, typenameF
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typefor_each_n
(ExPolicy &&policy, FwdIter first, Size count, F &&f)¶ Applies f to the result of dereferencing every iterator in the range [first, first + count), starting from first and proceeding to first + count - 1.
If
f returns a result, the result is ignored.- Note
Complexity: Applies f exactly count times.
If the type of first satisfies the requirements of a mutable iterator, f may apply non-constant functions through the dereferenced iterator.
Unlike its sequential form, the parallel overload of for_each does not return a copy of its Function parameter, since parallelization may not permit efficient state accumulation.
The application of function objects in parallel algorithm invoked with an execution policy object of type
sequenced_policy execute in sequential order in the calling thread.- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it applies user-provided function objects.FwdIter
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.Size
: The type of the argument specifying the number of elements to apply f to.F
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of for_each requires F to meet the requirements of CopyConstructible.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.count
: Refers to the number of elements starting at first the algorithm will be applied to.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:<ignored> pred(const Type &a);
The signature does not need to have const&. The type
Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.
The application of function objects in parallel algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The for_each_n algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. It returns first + count for non-negative values of count and first for negative values.
-
template<typename
Header hpx/parallel/algorithms/for_loop.hpp
¶
-
namespace
hpx
Functions
-
template<typename
I
, typename ...Args
>
voidfor_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
, typenameI
, typename ...Args
>
util::detail::algorithm_result<ExPolicy>::typefor_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
, typenameS
, typename ...Args
>
voidfor_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
, typenameI
, typenameS
, typename ...Args
>
util::detail::algorithm_result<ExPolicy>::typefor_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
, typenameSize
, typename ...Args
>
voidfor_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
, typenameI
, typenameSize
, typename ...Args
>
util::detail::algorithm_result<ExPolicy>::typefor_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
, typenameSize
, typenameS
, typename ...Args
>
voidfor_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.
-
template<typename
ExPolicy
, typenameI
, typenameSize
, typenameS
, typename ...Args
>
util::detail::algorithm_result<ExPolicy>::typefor_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
Header hpx/parallel/algorithms/for_loop_induction.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v2
¶ Functions
-
template<typename
T
>
constexpr detail::induction_stride_helper<T>induction
(T &&value, std::size_t stride)¶ The function template returns an induction object of unspecified type having a value type and encapsulating an initial value value of that type and, optionally, a stride.
For each element in the input range, a looping algorithm over input sequence S computes an induction value from an induction variable and ordinal position p within S by the formula i + p * stride if a stride was specified or i + p otherwise. This induction value is passed to the element access function.
If the value argument to induction is a non-const lvalue, then that lvalue becomes the live-out object for the returned induction object. For each induction object that has a live-out object, the looping algorithm assigns the value of i + n * stride to the live-out object upon return, where n is the number of elements in the input range.
- Return
This returns an induction object with value type T, initial value value, and (if specified) stride stride. If T is an lvalue of non-const type, value is used as the live-out object for the induction object; otherwise there is no live-out object.
- Template Parameters
T
: The value type to be used by the induction object.
- Parameters
value
: [in] The initial value to use for the induction objectstride
: [in] The (optional) stride to use for the induction object (default: 1)
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/for_loop_reduction.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v2
Functions
-
template<typename
T
, typenameOp
>
constexpr detail::reduction_helper<T, typename std::decay<Op>::type>reduction
(T &var, T const &identity, Op &&combiner)¶ The function template returns a reduction object of unspecified type having a value type and encapsulating an identity value for the reduction, a combiner function object, and a live-out object from which the initial value is obtained and into which the final value is stored.
A parallel algorithm uses reduction objects by allocating an unspecified number of instances, called views, of the reduction’s value type. Each view is initialized with the reduction object’s identity value, except that the live-out object (which was initialized by the caller) comprises one of the views. The algorithm passes a reference to a view to each application of an element-access function, ensuring that no two concurrently-executing invocations share the same view. A view can be shared between two applications that do not execute concurrently, but initialization is performed only once per view.
Modifications to the view by the application of element access functions accumulate as partial results. At some point before the algorithm returns, the partial results are combined, two at a time, using the reduction object’s combiner operation until a single value remains, which is then assigned back to the live-out object.
T shall meet the requirements of CopyConstructible and MoveAssignable. The expression var = combiner(var, var) shall be well formed.
- Template Parameters
T
: The value type to be used by the induction object.Op
: The type of the binary function (object) used to perform the reduction operation.
- Parameters
var
: [in,out] The life-out value to use for the reduction object. This will hold the reduced value after the algorithm is finished executing.identity
: [in] The identity value to use for the reduction operation.combiner
: [in] The binary function (object) used to perform a pairwise reduction on the elements.
- Note
In order to produce useful results, modifications to the view should be limited to commutative operations closely related to the combiner operation. For example if the combiner is plus<T>, incrementing the view would be consistent with the combiner but doubling it or assigning to it would not.
- Return
This returns a reduction object of unspecified type having a value type of T. When the return value is used by an algorithm, the reference to var is used as the live-out object, new views are initialized to a copy of identity, and views are combined by invoking the copy of combiner, passing it the two views to be combined.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/generate.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameF
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typegenerate
(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
, typenameFwdIter
, typenameSize
, typenameF
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typegenerate_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 toRet 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.
-
template<typename
Header hpx/parallel/algorithms/includes.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::typeincludes
(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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/inclusive_scan.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameOp
, typenameT
>
util::detail::algorithm_result<ExPolicy, FwdIter2>::typeinclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op, T init)¶ Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, init, *first, …, *(first + (i - result))).
The reduce operations in the parallel
inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate op.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.T
: The type of the value to be used as initial (and intermediate) values (deduced).Op
: The type of the binary function object used for the reduction operation.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.init
: The initial value for the generalized sum.op
: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type1 &b);
The signature does not need to have const&, but the function must not modify the objects passed to it. The types
Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.
The reduce operations in the parallel inclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum. If op is not mathematically associative, the behavior of inclusive_scan may be non-deterministic.- Return
The inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:
a1 when N is 1
op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameOp
>
util::detail::algorithm_result<ExPolicy, FwdIter2>::typeinclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op)¶ Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, *first, …, *(first + (i - result))).
The reduce operations in the parallel
inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate op.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.Op
: The type of the binary function object used for the reduction operation.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.op
: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type1 &b);
The signature does not need to have const&, but the function must not modify the objects passed to it. The types
Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.
The reduce operations in the parallel inclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum.- Return
The inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aN) is defined as:
a1 when N is 1
GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK)
GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, …, aN) where 1 < K+1 = M <= N.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeinclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest)¶ Assigns through each iterator i in [result, result + (last - first)) the value of gENERALIZED_NONCOMMUTATIVE_SUM(+, *first, …, *(first + (i - result))).
The reduce operations in the parallel
inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate op.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.
The reduce operations in the parallel inclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum.- Return
The inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aN) is defined as:
a1 when N is 1
GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, …, aK)
GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, …, aN) where 1 < K+1 = M <= N.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/is_heap.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameRandIter
, typenameComp
= detail::less, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::typeis_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
, typenameRandIter
, typenameComp
= detail::less, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, RandIter>::typeis_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/is_partitioned.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenamePred
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::typeis_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 tobool 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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/is_sorted.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::typeis_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 tobool 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
, typenameFwdIter
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter>::type>::typeis_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 tobool 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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/lexicographical_compare.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, bool>::type>::typelexicographical_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/merge.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameRandIter1
, typenameRandIter2
, typenameRandIter3
, typenameComp
= detail::less, typenameProj1
= util::projection_identity, typenameProj2
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(RandIter1), tag::in2(RandIter2), tag::out(RandIter3)>>::typemerge
(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_identityProj2
: 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 Type2proj1
: 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
, typenameRandIter
, typenameComp
= detail::less, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, RandIter>::typeinplace_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 Type2proj
: 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
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/minmax.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameProj
= util::projection_identity, typenameF
= detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter>::typemin_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
, typenameFwdIter
, typenameProj
= util::projection_identity, typenameF
= detail::less>
util::detail::algorithm_result<ExPolicy, FwdIter>::typemax_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
, typenameFwdIter
, typenameProj
= util::projection_identity, typenameF
= detail::less>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::min(FwdIter), tag::max(FwdIter)>>::typeminmax_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/mismatch.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::equal_to>
util::detail::algorithm_result<ExPolicy, std::pair<FwdIter1, FwdIter2>>::typemismatch
(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
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::equal_to>
util::detail::algorithm_result<ExPolicy, std::pair<FwdIter1, FwdIter2>>::typemismatch
(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).
-
template<typename
Header hpx/parallel/algorithms/move.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
>
util::detail::algorithm_result<ExPolicy, FwdIter2>::typemove
(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.
-
template<typename
Header hpx/parallel/algorithms/partition.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameBidirIter
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, BidirIter>::typestable_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
, typenameFwdIter
, typenamePred
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typepartition
(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
, typenameFwdIter1
, typenameFwdIter2
, typenameFwdIter3
, typenamePred
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in(FwdIter1), tag::out1(FwdIter2), tag::out2(FwdIter3)>>::typepartition_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/reduce.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameT
, typenameF
>
util::detail::algorithm_result<ExPolicy, T>::typereduce
(ExPolicy &&policy, FwdIter first, FwdIter last, T init, F &&f)¶ Returns GENERALIZED_SUM(f, init, *first, …, *(first + (last - first) - 1)).
The reduce operations in the parallel
reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate f.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter
: The type of the source begin and end iterators used (deduced). This iterator type must meet the requirements of an forward iterator.F
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.T
: The type of the value to be used as initial (and intermediate) values (deduced).
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type1 &b);
The signature does not need to have const&. The types
Type1 Ret must be such that an object of type FwdIter can be dereferenced and then implicitly converted to any of those types.init
: The initial value for the generalized sum.
The reduce operations in the parallel copy_if algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.- Return
The reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise. The reduce algorithm returns the result of the generalized sum over the elements given by the input range [first, last).
- Note
GENERALIZED_SUM(op, a1, …, aN) is defined as follows:
a1 when N is 1
op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:
b1, …, bN may be any permutation of a1, …, aN and
1 < K+1 = M <= N.
-
template<typename
ExPolicy
, typenameFwdIter
, typenameT
>
util::detail::algorithm_result<ExPolicy, T>::typereduce
(ExPolicy &&policy, FwdIter first, FwdIter last, T init)¶ Returns GENERALIZED_SUM(+, init, *first, …, *(first + (last - first) - 1)).
The reduce operations in the parallel
reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the operator+().
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter
: The type of the source begin and end iterators used (deduced). This iterator type must meet the requirements of an forward iterator.T
: The type of the value to be used as initial (and intermediate) values (deduced).
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.init
: The initial value for the generalized sum.
The reduce operations in the parallel copy_if algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.- Return
The reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise. The reduce algorithm returns the result of the generalized sum (applying operator+()) over the elements given by the input range [first, last).
- Note
GENERALIZED_SUM(+, a1, …, aN) is defined as follows:
a1 when N is 1
op(GENERALIZED_SUM(+, b1, …, bK), GENERALIZED_SUM(+, bM, …, bN)), where:
b1, …, bN may be any permutation of a1, …, aN and
1 < K+1 = M <= N.
-
template<typename
ExPolicy
, typenameFwdIter
>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<FwdIter>::value_type>::typereduce
(ExPolicy &&policy, FwdIter first, FwdIter last)¶ Returns GENERALIZED_SUM(+, T(), *first, …, *(first + (last - first) - 1)).
The reduce operations in the parallel
reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the operator+().
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter
: The type of the source begin and end iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.
The reduce operations in the parallel copy_if algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.- Return
The reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise (where T is the value_type of FwdIter). The reduce algorithm returns the result of the generalized sum (applying operator+()) over the elements given by the input range [first, last).
- Note
The type of the initial value (and the result type) T is determined from the value_type of the used FwdIter.
- Note
GENERALIZED_SUM(+, a1, …, aN) is defined as follows:
a1 when N is 1
op(GENERALIZED_SUM(+, b1, …, bK), GENERALIZED_SUM(+, bM, …, bN)), where:
b1, …, bN may be any permutation of a1, …, aN and
1 < K+1 = M <= N.
-
template<typename
Header hpx/parallel/algorithms/reduce_by_key.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameRanIter
, typenameRanIter2
, typenameFwdIter1
, typenameFwdIter2
, typenameCompare
= std::equal_to<typename std::iterator_traits<RanIter>::value_type>, typenameFunc
= std::plus<typename std::iterator_traits<RanIter2>::value_type>>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::typereduce_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/remove.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenamePred
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typeremove_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
, typenameFwdIter
, typenameT
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typeremove
(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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/remove_copy.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameT
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::typeremove_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
, typenameFwdIter1
, typenameFwdIter2
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::typeremove_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/replace.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameT1
, typenameT2
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typereplace
(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
, typenameFwdIter
, typenameF
, typenameT
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typereplace_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
, typenameFwdIter1
, typenameFwdIter2
, typenameT1
, typenameT2
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::typereplace_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
, typenameFwdIter1
, typenameFwdIter2
, typenameF
, typenameT
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::typereplace_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/reverse.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameBidirIter
>
util::detail::algorithm_result<ExPolicy, BidirIter>::typereverse
(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
, typenameBidirIter
, typenameFwdIter
>
util::detail::algorithm_result<ExPolicy, util::in_out_result<BidirIter, FwdIter>>::typereverse_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/rotate.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter, FwdIter>>::typerotate
(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
, typenameFwdIter1
, typenameFwdIter2
>
util::detail::algorithm_result<ExPolicy, util::in_out_result<FwdIter1, FwdIter2>>::typerotate_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/search.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameFwdIter2
, typenamePred
= detail::equal_to, typenameProj1
= util::projection_identity, typenameProj2
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typesearch
(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 tobool 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 respectivelyproj1
: 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
, typenameFwdIter
, typenameFwdIter2
, typenamePred
= detail::equal_to, typenameProj1
= util::projection_identity, typenameProj2
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typesearch_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 tobool 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 respectivelyproj1
: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter1 as a projection operation before the actual predicate is invoked.proj2
: Specifies the function (or function object) which will be invoked for each of the elements of type dereferenced FwdIter2 as a projection operation before the actual predicate is invoked.
The comparison operations in the parallel search_n algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The search_n algorithm returns a hpx::future<FwdIter> if the execution policy is of type task_execution_policy and returns FwdIter otherwise. The search_n algorithm returns an iterator to the beginning of the last subsequence [s_first, s_last) in range [first, first+count). If the length of the subsequence [s_first, s_last) is greater than the length of the range [first, first+count), first is returned. Additionally if the size of the subsequence is empty or no subsequence is found, first is also returned.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/set_difference.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameFwdIter3
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter3>::type>::typeset_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/set_intersection.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameFwdIter3
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter3>::type>::typeset_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/set_symmetric_difference.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameFwdIter3
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter3>::type>::typeset_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/set_union.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameFwdIter3
, typenamePred
= detail::less>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter3>::type>::typeset_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/sort.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameRandomIt
, typenameCompare
= detail::less, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, RandomIt>::typesort
(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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/sort_by_key.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameKeyIter
, typenameValueIter
, typenameCompare
= detail::less>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in1(KeyIter), tag::in2(ValueIter)>>::typesort_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/stable_sort.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameRandomIt
, typenameSentinel
, typenameProj
= util::projection_identity, typenameCompare
= detail::less>
util::detail::algorithm_result<ExPolicy, RandomIt>::typestable_sort
(ExPolicy &&policy, RandomIt first, Sentinel last, Compare &&comp = Compare(), Proj &&proj = Proj())¶ Sorts the elements in the range [first, last) in ascending order. The relative order of equal elements is preserved. The function uses the given comparison function object comp (defaults to using operator<()).
A sequence is sorted with respect to a comparator
comp and a projection proj if for every iterator i pointing to the sequence and every non-negative integer n such that i + n is a valid iterator pointing to an element of the sequence, and INVOKE(comp, INVOKE(proj, *(i + n)), INVOKE(proj, *i)) == false.- Note
Complexity: O(Nlog(N)), where N = std::distance(first, last) comparisons.
comp has to induce a strict weak ordering on the values.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it applies user-provided function objects.RandomIt
: The type of the source iterators used (deduced). This iterator type must meet the requirements of a random access iterator.Sentinel
: The type of the end iterators used (deduced). This iterator type must meet the requirements of a random access iterator and must be a valid sentinel type for RandomIt.Comp
: The type of the function/function object to use (deduced).Proj
: The type of an optional projection function. This defaults to util::projection_identity
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.comp
: comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator.proj
: Specifies the function (or function object) which will be invoked for each pair of elements as a projection operation before the actual predicate comp is invoked.
The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
The application of function objects in parallel algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The stable_sort algorithm returns a hpx::future<RandomIt> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns RandomIt otherwise. The algorithm returns an iterator pointing to the first element after the last element in the input sequence.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/swap_ranges.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeswap_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/transform.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::typetransform
(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
, typenameFwdIter1
, typenameFwdIter2
, typenameFwdIter3
, typenameF
, typenameProj1
= util::projection_identity, typenameProj2
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(FwdIter3)>>::typetransform
(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_identityProj2
: 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
, typenameFwdIter1
, typenameFwdIter2
, typenameFwdIter3
, typenameF
, typenameProj1
= util::projection_identity, typenameProj2
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_tuple<tag::in1(FwdIter1), tag::in2(FwdIter2), tag::out(FwdIter3)>>::typetransform
(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_identityProj2
: 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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/transform_exclusive_scan.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameT
, typenameOp
, typenameConv
>
util::detail::algorithm_result<ExPolicy, FwdIter2>::typetransform_exclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, T init, Op &&op, Conv &&conv)¶ Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, conv(*first), …, conv(*(first + (i - result) - 1))).
The reduce operations in the parallel
transform_exclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicates op and conv.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.Conv
: The type of the unary function object used for the conversion operation.T
: The type of the value to be used as initial (and intermediate) values (deduced).Op
: The type of the binary function object used for the reduction operation.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.conv
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:R fun(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.init
: The initial value for the generalized sum.op
: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type1 &b);
The signature does not need to have const&, but the function must not modify the objects passed to it. The types
Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.
The reduce operations in the parallel transform_exclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
Neither
conv nor op shall invalidate iterators or subranges, or modify elements in the ranges [first,last) or [result,result + (last - first)).- Return
The transform_exclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The transform_exclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:
a1 when N is 1
op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN) where 1 < K+1 = M <= N.
The behavior of transform_exclusive_scan may be non-deterministic for a non-associative predicate.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/transform_inclusive_scan.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameOp
, typenameConv
, typenameT
>
util::detail::algorithm_result<ExPolicy, FwdIter2>::typetransform_inclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op, Conv &&conv, T init)¶ Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, init, conv(*first), …, conv(*(first + (i - result)))).
The reduce operations in the parallel
transform_inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate op.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.Conv
: The type of the unary function object used for the conversion operation.T
: The type of the value to be used as initial (and intermediate) values (deduced).Op
: The type of the binary function object used for the reduction operation.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.conv
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:R fun(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.init
: The initial value for the generalized sum.op
: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type1 &b);
The signature does not need to have const&, but the function must not modify the objects passed to it. The types
Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.
The reduce operations in the parallel transform_inclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
Neither
conv nor op shall invalidate iterators or subranges, or modify elements in the ranges [first,last) or [result,result + (last - first)).- Return
The transform_inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The transform_inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:
a1 when N is 1
op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.
The difference between exclusive_scan and transform_inclusive_scan is that transform_inclusive_scan includes the ith input element in the ith sum. If op is not mathematically associative, the behavior of transform_inclusive_scan may be non-deterministic.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameConv
, typenameOp
>
util::detail::algorithm_result<ExPolicy, FwdIter2>::typetransform_inclusive_scan
(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Op &&op, Conv &&conv)¶ Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(op, conv(*first), …, conv(*(first + (i - result)))).
The reduce operations in the parallel
transform_inclusive_scan algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicate op.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.Conv
: The type of the unary function object used for the conversion operation.T
: The type of the value to be used as initial (and intermediate) values (deduced).Op
: The type of the binary function object used for the reduction operation.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.conv
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:R fun(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.op
: Specifies the function (or function object) which will be invoked for each of the values of the input sequence. This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type1 &b);
The signature does not need to have const&, but the function must not modify the objects passed to it. The types
Type1 and Ret must be such that an object of a type as given by the input sequence can be implicitly converted to any of those types.
The reduce operations in the parallel transform_inclusive_scan algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
Neither
conv nor op shall invalidate iterators or subranges, or modify elements in the ranges [first,last) or [result,result + (last - first)).- Return
The transform_inclusive_scan algorithm returns a hpx::future<FwdIter2> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter2 otherwise. The transform_inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.
- Note
GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aN) is defined as:
a1 when N is 1
op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, …, aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, …, aN)) where 1 < K+1 = M <= N.
The difference between exclusive_scan and transform_inclusive_scan is that transform_inclusive_scan includes the ith input element in the ith sum.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/transform_reduce.hpp
¶
-
namespace
hpx
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameT
, typenameReduce
, typenameConvert
>
util::detail::algorithm_result<ExPolicy, T>::typetransform_reduce
(ExPolicy &&policy, FwdIter first, FwdIter last, T init, Reduce &&red_op, Convert &&conv_op)¶ Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).
The reduce operations in the parallel
transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: O(last - first) applications of the predicates red_op and conv_op.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.F
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.T
: The type of the value to be used as initial (and intermediate) values (deduced).Reduce
: The type of the binary function object used for the reduction operation.Convert
: The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.last
: Refers to the end of the sequence of elements the algorithm will be applied to.conv_op
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:R fun(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.init
: The initial value for the generalized sum.red_op
: Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:Ret fun(const Type1 &a, const Type2 &b);
The signature does not need to have const&, but the function must not modify the objects passed to it. The types
Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.
The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
The difference between
transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.- Return
The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type parallel_task_policy and returns T otherwise. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).
- Note
GENERALIZED_SUM(op, a1, …, aN) is defined as follows:
a1 when N is 1
op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:
b1, …, bN may be any permutation of a1, …, aN and
1 < K+1 = M <= N.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
, typenameT
>
util::detail::algorithm_result<ExPolicy, T>::typetransform_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
, typenameFwdIter1
, typenameFwdIter2
, typenameT
, typenameReduce
, typenameConvert
>
util::detail::algorithm_result<ExPolicy, T>::typetransform_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 toRet 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.
-
template<typename
Header hpx/parallel/algorithms/transform_reduce_binary.hpp
¶
Header hpx/parallel/algorithms/uninitialized_copy.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeuninitialized_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
, typenameFwdIter1
, typenameSize
, typenameFwdIter2
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy, FwdIter2>::type>::typeuninitialized_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/uninitialized_default_construct.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
>
util::detail::algorithm_result<ExPolicy>::typeuninitialized_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
, typenameFwdIter
, typenameSize
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typeuninitialized_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/uninitialized_fill.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenameT
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy>::type>::typeuninitialized_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
, typenameFwdIter
, typenameSize
, typenameT
>
std::enable_if<execution::is_execution_policy<ExPolicy>::value, typename util::detail::algorithm_result<ExPolicy>::type>::typeuninitialized_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/uninitialized_move.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameFwdIter2
>
util::detail::algorithm_result<ExPolicy, FwdIter2>::typeuninitialized_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
, typenameFwdIter1
, typenameSize
, typenameFwdIter2
>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::typeuninitialized_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/uninitialized_value_construct.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
>
util::detail::algorithm_result<ExPolicy>::typeuninitialized_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
, typenameFwdIter
, typenameSize
>
util::detail::algorithm_result<ExPolicy, FwdIter>::typeuninitialized_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/algorithms/unique.hpp
¶
-
namespace
hpx
-
namespace
parallel
-
namespace
v1
Functions
-
template<typename
ExPolicy
, typenameFwdIter
, typenamePred
= detail::equal_to, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, FwdIter>::typeunique
(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 Type2proj
: 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
, typenameFwdIter1
, typenameFwdIter2
, typenamePred
= detail::equal_to, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>>::typeunique_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.
-
template<typename
-
namespace
-
namespace
Header hpx/parallel/container_algorithms.hpp
¶
Header hpx/parallel/container_algorithms/all_any_none.hpp
¶
-
namespace
hpx
-
namespace
ranges
¶ Functions
-
template<typename
ExPolicy
, typenameRng
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::typenone_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
, typenameRng
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::typeany_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
, typenameRng
, typenameF
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, bool>::typeall_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.
-
template<typename
-
namespace
Header hpx/parallel/container_algorithms/copy.hpp
¶
-
namespace
hpx
-
namespace
ranges
Functions
-
template<typename
ExPolicy
, typenameIter1
, typenameSent1
, typenameFwdIter
>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_result<Iter1, Iter>>::typecopy
(ExPolicy &&policy, Iter1 iter, Sent1 sent, FwdIter dest)¶ Copies the elements in the range, defined by [first, last), to another range beginning at dest.
The assignments in the parallel
copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs exactly last - first assignments.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.Iter1
: The type of the begin source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.Sent1
: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter1.FwdIter
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.iter
: Refers to the beginning of the sequence of elements the algorithm will be applied to.sent
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.
The assignments in the parallel copy algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy algorithm returns a hpx::future<ranges::copy_result<FwdIter1, FwdIter> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_result<FwdIter1, FwdIter> otherwise. The copy algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
ExPolicy
, typenameRng
, typenameFwdIter
>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_result<typename hpx::traits::range_traits<Rng>::iterator_type, FwdIter>>::typecopy
(ExPolicy &&policy, Rng &&rng, FwdIter dest)¶ Copies the elements in the range rng to another range beginning at dest.
The assignments in the parallel
copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs exactly std::distance(begin(rng), end(rng)) assignments.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.Rng
: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.FwdIter
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.rng
: Refers to the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.
The assignments in the parallel copy algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy algorithm returns a hpx::future<ranges::copy_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_result<iterator_t<Rng>, FwdIter2> otherwise. The copy algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameSize
, typenameFwdIter2
>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_n_result<FwdIter1, FwdIter2>>::typecopy_n
(ExPolicy &&policy, FwdIter1 first, Size count, FwdIter2 dest)¶ Copies the elements in the range [first, first + count), starting from first and proceeding to first + count - 1., to another range beginning at dest.
The assignments in the parallel
copy_n algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs exactly count assignments, if count > 0, no assignments otherwise.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.Size
: The type of the argument specifying the number of elements to apply f to.FwdIter2
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an forward iterator.
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.first
: Refers to the beginning of the sequence of elements the algorithm will be applied to.count
: Refers to the number of elements starting at first the algorithm will be applied to.dest
: Refers to the beginning of the destination range.
The assignments in the parallel copy_n algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy_n algorithm returns a hpx::future<ranges::copy_n_result<FwdIter1, FwdIter2> > if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_n_result<FwdIter1, FwdIter2> otherwise. The copy algorithm returns the pair of the input iterator forwarded to the first element after the last in the input sequence and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
ExPolicy
, typenameFwdIter1
, typenameSent1
, typenameFwdIter
, typenameF
, typenameProj
= hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_if_result<typename hpx::traits::range_traits<Rng>::iterator_type, OutIter>>::typecopy_if
(ExPolicy &&policy, FwdIter1 iter, Sent1 sent, FwdIter dest, F &&f, Proj &&proj = Proj())¶ Copies the elements in the range, defined by [first, last) to another range beginning at dest. Copies only the elements for which the predicate f returns true. The order of the elements that are not removed is preserved.
The assignments in the parallel
copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs not more than std::distance(begin(rng), end(rng)) assignments, exactly std::distance(begin(rng), end(rng)) applications of the predicate f.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.FwdIter1
: The type of the begin source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.Sent1
: The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for FwdIter1.FwdIter
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.F
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.Proj
: The type of an optional projection function. This defaults to util::projection_identity
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.iter
: Refers to the beginning of the sequence of elements the algorithm will be applied to.sent
: Refers to the end of the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:bool pred(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type InIter can be dereferenced and then implicitly converted to Type.proj
: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.
The assignments in the parallel copy_if algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy_if algorithm returns a hpx::future<ranges::copy_if_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_if_result<iterator_t<Rng>, FwdIter2> otherwise. The copy_if algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
ExPolicy
, typenameRng
, typenameOutIter
, typenameF
, typenameProj
= hpx::parallel::util::projection_identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, hpx::ranges::copy_if_result<typename hpx::traits::range_traits<Rng>::iterator_type, OutIter>>::typecopy_if
(ExPolicy &&policy, Rng &&rng, OutIter dest, F &&f, Proj &&proj = Proj())¶ Copies the elements in the range rng to another range beginning at dest. Copies only the elements for which the predicate f returns true. The order of the elements that are not removed is preserved.
The assignments in the parallel
copy_if algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.- Note
Complexity: Performs not more than std::distance(begin(rng), end(rng)) assignments, exactly std::distance(begin(rng), end(rng)) applications of the predicate f.
- Template Parameters
ExPolicy
: The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.Rng
: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.OutIter
: The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.F
: The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of copy_if requires F to meet the requirements of CopyConstructible.Proj
: The type of an optional projection function. This defaults to util::projection_identity
- Parameters
policy
: The execution policy to use for the scheduling of the iterations.rng
: Refers to the sequence of elements the algorithm will be applied to.dest
: Refers to the beginning of the destination range.f
: Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last).This is an unary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:bool pred(const Type &a);
The signature does not need to have const&, but the function must not modify the objects passed to it. The type
Type must be such that an object of type InIter can be dereferenced and then implicitly converted to Type.proj
: Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.
The assignments in the parallel copy_if algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
- Return
The copy_if algorithm returns a hpx::future<ranges::copy_if_result<iterator_t<Rng>, FwdIter2>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::copy_if_result<iterator_t<Rng>, FwdIter2> otherwise. The copy_if algorithm returns the pair of the input iterator last and the output iterator to the element in the destination range, one past the last element copied.
-
template<typename
-
namespace
Header hpx/parallel/container_algorithms/count.hpp
¶
-
namespace
hpx
-
namespace
ranges
Functions
-
template<typename
ExPolicy
, typenameRng
, typenameT
, typenameProj
= util::projection_identity>
util::detail::algorithm_result<ExPolicy, typename std::iterator_traits<typename hpx::traits::range_traits<Rng>::iterator_type>::difference_type>::typecount
(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 element
-
template<typename
-
namespace