hpx::ranges::set_intersection#

Defined in header hpx/algorithm.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 ExPolicy, typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Pred = hpx::parallel::detail::less, typename Proj1 = hpx::identity, typename Proj2 = hpx::identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, set_intersection_result<Iter1, Iter2, Iter3>>::type set_intersection(ExPolicy &&policy, Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

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.

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

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.

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.

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.

  • Iter1 – The type of the source iterators used (deduced) representing the first sequence. 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.

  • Iter2 – The type of the source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an forward iterator.

  • Sent2 – The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

  • Iter3 – 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<>

  • Proj1 – The type of an optional projection function applied to the first sequence. This defaults to hpx::identity

  • Proj2 – The type of an optional projection function applied to the second sequence. This defaults to hpx::identity

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

  • 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 op 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 op is invoked.

Returns

The set_intersection algorithm returns a hpx::future<ranges::set_intersection_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_intersection_result<Iter1, Iter2, Iter3> otherwise. The set_intersection algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Iter3, typename Pred = hpx::parallel::detail::less, typename Proj1 = hpx::identity, typename Proj2 = hpx::identity>
hpx::parallel::util::detail::algorithm_result<ExPolicy, set_intersection_result<hpx::traits::range_iterator_t<Rng1>, hpx::traits::range_iterator_t<Rng2>, Iter3>> set_intersection(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

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.

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

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.

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.

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.

  • Rng1 – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2 – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter3 – 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<>

  • Proj1 – The type of an optional projection function applied to the first sequence. This defaults to hpx::identity

  • Proj2 – The type of an optional projection function applied to the second sequence. This defaults to hpx::identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng1 – Refers to the first sequence of elements the algorithm will be applied to.

  • rng2 – Refers to the second sequence of elements 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

  • 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 op 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 op is invoked.

Returns

The set_intersection algorithm returns a hpx::future<ranges::set_intersection_result<Iter1, Iter2, Iter3>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns ranges::set_intersection_result<Iter1, Iter2, Iter3> otherwise. where Iter1 is range_iterator_t<Rng1> and Iter2 is range_iterator_t<Rng2> The set_intersection algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename Iter1, typename Sent1, typename Iter2, typename Sent2, typename Iter3, typename Pred = hpx::parallel::detail::less, typename Proj1 = hpx::identity, typename Proj2 = hpx::identity>
set_intersection_result<Iter1, Iter2, Iter3> set_intersection(Iter1 first1, Sent1 last1, Iter2 first2, Sent2 last2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

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.

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.

Template Parameters
  • Iter1 – The type of the source iterators used (deduced) representing the first sequence. 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.

  • Iter2 – The type of the source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an forward iterator.

  • Sent2 – The type of the end source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an sentinel for Iter2.

  • Iter3 – 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<>

  • Proj1 – The type of an optional projection function applied to the first sequence. This defaults to hpx::identity

  • Proj2 – The type of an optional projection function applied to the second sequence. This defaults to hpx::identity

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

  • 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 op 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 op is invoked.

Returns

The set_intersection algorithm returns ranges::set_intersection_result<Iter1, Iter2, Iter3>. The set_intersection algorithm returns the output iterator to the element in the destination range, one past the last element copied.

template<typename Rng1, typename Rng2, typename Iter3, typename Pred = hpx::parallel::detail::less, typename Proj1 = hpx::identity, typename Proj2 = hpx::identity>
set_intersection_result<hpx::traits::range_iterator_t<Rng1>, hpx::traits::range_iterator_t<Rng2>, Iter3> set_intersection(Rng1 &&rng1, Rng2 &&rng2, Iter3 dest, Pred &&op = Pred(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

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.

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.

Template Parameters
  • Rng1 – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Rng2 – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter3 – 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<>

  • Proj1 – The type of an optional projection function applied to the first sequence. This defaults to hpx::identity

  • Proj2 – The type of an optional projection function applied to the second sequence. This defaults to hpx::identity

Parameters
  • rng1 – Refers to the first sequence of elements the algorithm will be applied to.

  • rng2 – Refers to the second sequence of elements 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

  • 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 op 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 op is invoked.

Returns

The set_intersection algorithm returns ranges::set_intersection_result<Iter1, Iter2, Iter3>. where Iter1 is range_iterator_t<Rng1> and Iter2 is range_iterator_t<Rng2> The set_intersection algorithm returns the output iterator to the element in the destination range, one past the last element copied.