hpx/parallel/container_algorithms/adjacent_find.hpp

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

namespace hpx
namespace ranges

Functions

template<typename FwdIter, typename Sent, typename Proj = hpx::parallel::util::projection_identity, typename Pred = detail::equal_to>
FwdIter adjacent_find(FwdIter first, Sent last, Pred &&pred = Pred(), Proj &&proj = Proj())

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

Return

The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

Template Parameters
  • FwdIter: The type of the source iterators used for the range (deduced). This iterator type must meet the requirements of an forward iterator.

  • Sent: The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

  • Proj: The type of an optional projection function. This defaults to util::projection_identity

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

    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 .

  • 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 Rng, typename Proj = hpx::parallel::util::projection_identity, typename Pred = detail::equal_to>
hpx::traits::range_traits<Rng>::iterator_type adjacent_find(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())

Searches the range rng for two consecutive identical elements.

Note

Complexity: Exactly the smaller of (result - std::begin(rng)) + 1 and (std::begin(rng) - std::end(rng)) - 1 applications of the predicate where result is the value returned

Return

The adjacent_find algorithm returns an iterator to the first of the identical elements. If no such elements are found, last is returned.

Template Parameters
  • Rng: The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • Proj: The type of an optional projection function. This defaults to util::projection_identity

  • Pred: The type of an optional function/function object to use.

Parameters
  • rng: Refers to the sequence of elements 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:

    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 .

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