hpx/parallel/algorithms/find.hpp
hpx/parallel/algorithms/find.hpp#
See Public API for a list of names and headers that are part of the public HPX API.
-
namespace hpx
Functions
-
template<typename ExPolicy, typename FwdIter, typename T>
util::detail::algorithm_result<ExPolicy, FwdIter>::type find(ExPolicy &&policy, FwdIter first, FwdIter last, T const &val)# Returns the first element in the range [first, last) that is equal to value. Executed according to the policy.
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.
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.
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
- Returns
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 InIter, typename T>
InIter find(InIter first, InIter last, T const &val)# Returns the first element in the range [first, last) that is equal to value. Executed according to the policy.
Note
Complexity: At most last - first applications of the operator==().
- Template Parameters
InIter – The type of the source iterators used for the first range (deduced). This iterator type must meet the requirements of an input iterator.
T – The type of the value to find (deduced).
- Parameters
first – Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.
last – Refers to the end of the sequence of elements of the first range the algorithm will be applied to.
val – the value to compare the elements to
- Returns
The find algorithm returns a InIter. The find algorithm returns the first element in the range [first,last) that is equal to val. If no such element in the range of [first,last) is equal to val, then the algorithm returns last.
-
template<typename ExPolicy, typename FwdIter, typename F>
util::detail::algorithm_result<ExPolicy, FwdIter>::type find_if(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)# Returns the first element in the range [first, last) for which predicate f returns true. Executed according to the policy.
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.
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.
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:
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.bool pred(const Type &a);
- Returns
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 InIter, typename F>
InIter find_if(InIter first, InIter last, F &&f)# Returns the first element in the range [first, last) for which predicate f returns true.
Note
Complexity: At most last - first applications of the predicate.
- Template Parameters
InIter – The type of the source iterators used for the first range (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 equal requires F to meet the requirements of CopyConstructible.
- Parameters
first – Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.
last – Refers to the end of the sequence of elements of the first range the algorithm will be applied to.
f – The unary predicate which returns true for the required element. The signature of the predicate should be equivalent to:
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 InIter can be dereferenced and then implicitly converted to Type.bool pred(const Type &a);
- Returns
The find_if algorithm returns a InIter. The find_if algorithm returns the first element in the range [first,last) that satisfies the predicate f. If no such element exists that satisfies the predicate f, the algorithm returns last.
-
template<typename ExPolicy, typename FwdIter, typename F>
util::detail::algorithm_result<ExPolicy, FwdIter>::type find_if_not(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)# Returns the first element in the range [first, last) for which predicate f returns false. Executed according to the policy.
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.
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.
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:
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.bool pred(const Type &a);
- Returns
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 FwdIter, typename F>
FwdIter find_if_not(FwdIter first, FwdIter last, F &&f)# Returns the first element in the range [first, last) for which predicate f returns false.
Note
Complexity: At most last - first applications of the predicate.
- Template Parameters
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
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:
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.bool pred(const Type &a);
- Returns
The find_if_not algorithm returns a FwdIter. The find_if_not algorithm returns the first element in the range [first, last) that does not satisfy the predicate f. If no such element exists that does not satisfy the predicate f, the algorithm returns last.
-
template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter1>::type find_end(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2, Pred &&op = Pred())# Returns the last subsequence of elements [first2, last2) found in the range [first, last) using the given predicate op to compare elements. Executed according to the policy.
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.
The comparison operations in the parallel find_end algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
This overload of find_end is available if the user decides to provide the algorithm their own predicate op.
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<>
- 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:
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.bool pred(const Type1 &a, const Type2 &b);
- Returns
The find_end algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The find_end algorithm returns an iterator to the beginning of the last subsequence [first2, last2) in range [first, last). If the length of the subsequence [first2, last2) is greater than the length of the range [first1, last1), last1 is returned. Additionally if the size of the subsequence is empty or no subsequence is found, last1 is also returned.
-
template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, FwdIter1>::type find_end(ExPolicy &&policy, FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2)# Returns the last subsequence of elements [first2, last2) found in the range [first, last). Elements are compared using operator==. Executed according to the policy.
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.
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.
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.
- 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.
- Returns
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 FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
FwdIter1 find_end(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 op to compare elements.
This overload of find_end is available if the user decides to provide the algorithm their own predicate op.
Note
Complexity: at most S*(N-S+1) comparisons where S = distance(first2, last2) and N = distance(first1, last1).
- Template Parameters
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<>
- Parameters
first1 – Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.
last1 – Refers to the end of the sequence of elements of the first range the algorithm will be applied to.
first2 – Refers to the beginning of the sequence of elements 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:
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.bool pred(const Type1 &a, const Type2 &b);
- Returns
The find_end algorithm returns a FwdIter1. 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 FwdIter1, typename FwdIter2>
FwdIter1 find_end(FwdIter1 first1, FwdIter1 last1, FwdIter2 first2, FwdIter2 last2)# Returns the last subsequence of elements [first2, last2) found in the range [first, last). Elements are compared using operator==.
Note
Complexity: at most S*(N-S+1) comparisons where S = distance(first2, last2) and N = distance(first1, last1).
- Template Parameters
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.
- Parameters
first1 – Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.
last1 – Refers to the end of the sequence of elements of the first range the algorithm will be applied to.
first2 – Refers to the beginning of the sequence of elements the algorithm will be searching for.
last2 – Refers to the end of the sequence of elements of the algorithm will be searching for.
- Returns
The find_end algorithm returns a FwdIter1. The find_end algorithm returns an iterator to the beginning of the last subsequence [first2, last2) in range [first, last). If the length of the subsequence [first2, last2) is greater than the length of the range [first1, last1), last1 is returned. Additionally if the size of the subsequence is empty or no subsequence is found, last1 is also returned.
-
template<typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
util::detail::algorithm_result<ExPolicy, FwdIter1>::type find_first_of(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 s_first, FwdIter2 s_last, Pred &&op = Pred())# Searches the range [first, last) for any elements in the range [s_first, s_last). Uses binary predicate op to compare elements. Executed according to the policy.
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.
The comparison operations in the parallel find_first_of algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
This overload of find_first_of is available if the user decides to provide the algorithm their own predicate op.
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<>
- 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:
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.bool pred(const Type1 &a, const Type2 &b);
- Returns
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.
-
template<typename ExPolicy, typename FwdIter1, typename FwdIter2>
util::detail::algorithm_result<ExPolicy, FwdIter1>::type find_first_of(ExPolicy &&policy, FwdIter1 first, FwdIter1 last, FwdIter2 s_first, FwdIter2 s_last)# Searches the range [first, last) for any elements in the range [s_first, s_last). Elements are compared using operator==. Executed according to the policy.
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.
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.
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.
- 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.
- Returns
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.
-
template<typename FwdIter1, typename FwdIter2, typename Pred = detail::equal_to>
FwdIter1 find_first_of(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 op to compare elements.
This overload of find_first_of is available if the user decides to provide the algorithm their own predicate op.
Note
Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = distance(first, last).
- Template Parameters
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
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:
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.bool pred(const Type1 &a, const Type2 &b);
- Returns
The find_first_of algorithm returns a FwdIter1. 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.
-
template<typename FwdIter1, typename FwdIter2>
FwdIter1 find_first_of(FwdIter1 first, FwdIter1 last, FwdIter2 s_first, FwdIter2 s_last)# Searches the range [first, last) for any elements in the range [s_first, s_last). Elements are compared using operator==.
Note
Complexity: at most (S*N) comparisons where S = distance(s_first, s_last) and N = distance(first, last).
- Template Parameters
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.
- Parameters
first – Refers to the beginning of the sequence of elements of the first range the algorithm will be applied to.
last – Refers to the end of the sequence of elements of the first range the algorithm will be applied to.
s_first – Refers to the beginning of the sequence of elements the algorithm will be searching for.
s_last – Refers to the end of the sequence of elements of the algorithm will be searching for.
- Returns
The find_first_of algorithm returns a FwdIter1. 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.
-
template<typename ExPolicy, typename FwdIter, typename T>