hpx::find_if

Contents

hpx::find_if#

Defined in header hpx/algorithm.hpp.

See Public API for a list of names and headers that are part of the public HPX API.

See also:

template<typename ExPolicy, typename FwdIter, typename F>
util::detail::algorithm_result_t<ExPolicy, FwdIter> hpx::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:

    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.

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

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

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.