hpx/parallel/algorithms/adjacent_find.hpp
hpx/parallel/algorithms/adjacent_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 InIter, typename Pred = hpx::parallel::v1::detail::equal_to>
InIter adjacent_find(InIter first, InIter last, Pred &&pred = Pred())# Searches the range [first, last) for two consecutive identical elements.
Note
Complexity: Exactly the smaller of (result - first) + 1 and (last - first) - 1 application of the predicate where result is the value returned
- Template Parameters
InIter – The type of the source iterators used for the range (deduced). This iterator type must meet the requirements of an input iterator.
Pred – The type of an optional function/function object to use.
- Parameters
first – Refers to the beginning of the sequence of elements of the range the algorithm will be applied to.
last – Refers to the end of the sequence of elements of the range the algorithm will be applied to.
pred – The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:
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 InIter can be dereferenced and then implicitly converted to Type1 .bool pred(const Type1 &a, const Type1 &b);
- Returns
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 ExPolicy, typename FwdIter, typename Pred = hpx::parallel::v1::detail::equal_to>
parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type adjacent_find(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred = Pred())# Searches the range [first, last) for two consecutive identical elements. This version uses the given binary predicate pred
The comparison operations in the parallel adjacent_find invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
The comparison operations in the parallel adjacent_find invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
This overload of adjacent_find is available if the user decides to provide their algorithm their own binary predicate pred.
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 a forward iterator.
Pred – The type of an optional function/function object to use. Unlike its sequential form, the parallel overload of adjacent_find requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>
- Parameters
policy – The execution policy to use for the scheduling of the iterations.
first – Refers to the beginning of the sequence of elements of the range the algorithm will be applied to.
last – Refers to the end of the sequence of elements of the range the algorithm will be applied to.
pred – The binary predicate which returns true if the elements should be treated as equal. The signature should be equivalent to the following:
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 .bool pred(const Type1 &a, const Type1 &b);
- Returns
The adjacent_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 adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.
-
template<typename InIter, typename Pred = hpx::parallel::v1::detail::equal_to>