thrust::set_intersection#
Overloads#
set_intersection(exec, first1, last1, first2, last2, result)#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::set_intersection( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
set_intersectionconstructs a sorted range that is the intersection of sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_intersectionperforms the “intersection” operation from set theory: the output range contains a copy of every element that is contained in both[first1, last1)and[first2, last2). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if a value appearsmtimes in[first1, last1)andntimes in[first2, last2)(wheremmay be zero), then it appearsmin(m,n)times in the output range.set_intersectionis stable, meaning that both elements are copied from the first range rather than the second, and that the relative order of elements in the output range is the same as in the first input range.This version of
set_intersectioncompares objects usingoperator<.The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
set_intersectionto compute the set intersection of two sets of integers sorted in ascending order using thethrust::hostexecution policy for parallelization:#include <thrust/set_operations.h> #include <thrust/execution_policy.h> ... int A1[6] = {1, 3, 5, 7, 9, 11}; int A2[7] = {1, 1, 2, 3, 5, 8, 13}; int result[7]; int *result_end = thrust::set_intersection(thrust::host, A1, A1 + 6, A2, A2 + 7, result); // result is now {1, 3, 5}
See also
includesSee also
See also
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first1 – The beginning of the first input range.
last1 – The end of the first input range.
first2 – The beginning of the second input range.
last2 – The end of the second input range.
result – The beginning of the output range.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator,
InputIterator1andInputIterator2have the samevalue_type,InputIterator1'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator1'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator1'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.InputIterator2 – is a model of Input Iterator,
InputIterator2andInputIterator1have the samevalue_type,InputIterator2'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator2'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator2'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.OutputIterator – is a model of Output Iterator.
- Returns:
The end of the output range.
- Pre:
The ranges
[first1, last1)and[first2, last2)shall be sorted with respect tooperator<.- Pre:
The resulting range shall not overlap with either input range.
set_intersection(first1, last1, first2, last2, result)#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::set_intersection( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
set_intersectionconstructs a sorted range that is the intersection of sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_intersectionperforms the “intersection” operation from set theory: the output range contains a copy of every element that is contained in both[first1, last1)and[first2, last2). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if a value appearsmtimes in[first1, last1)andntimes in[first2, last2)(wheremmay be zero), then it appearsmin(m,n)times in the output range.set_intersectionis stable, meaning that both elements are copied from the first range rather than the second, and that the relative order of elements in the output range is the same as in the first input range.This version of
set_intersectioncompares objects usingoperator<.The following code snippet demonstrates how to use
set_intersectionto compute the set intersection of two sets of integers sorted in ascending order.#include <thrust/set_operations.h> ... int A1[6] = {1, 3, 5, 7, 9, 11}; int A2[7] = {1, 1, 2, 3, 5, 8, 13}; int result[7]; int *result_end = thrust::set_intersection(A1, A1 + 6, A2, A2 + 7, result); // result is now {1, 3, 5}
See also
includesSee also
See also
See also
See also
See also
- Parameters:
first1 – The beginning of the first input range.
last1 – The end of the first input range.
first2 – The beginning of the second input range.
last2 – The end of the second input range.
result – The beginning of the output range.
- Template Parameters:
InputIterator1 – is a model of Input Iterator,
InputIterator1andInputIterator2have the samevalue_type,InputIterator1'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator1'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator1'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.InputIterator2 – is a model of Input Iterator,
InputIterator2andInputIterator1have the samevalue_type,InputIterator2'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator2'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator2'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.OutputIterator – is a model of Output Iterator.
- Returns:
The end of the output range.
- Pre:
The ranges
[first1, last1)and[first2, last2)shall be sorted with respect tooperator<.- Pre:
The resulting range shall not overlap with either input range.
set_intersection(exec, first1, last1, first2, last2, result, comp)#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename StrictWeakCompare>
OutputIterator thrust::set_intersection( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
- StrictWeakCompare comp,
set_intersectionconstructs a sorted range that is the intersection of sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_intersectionperforms the “intersection” operation from set theory: the output range contains a copy of every element that is contained in both[first1, last1)and[first2, last2). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if a value appearsmtimes in[first1, last1)andntimes in[first2, last2)(wheremmay be zero), then it appearsmin(m,n)times in the output range.set_intersectionis stable, meaning that both elements are copied from the first range rather than the second, and that the relative order of elements in the output range is the same as in the first input range.This version of
set_intersectioncompares elements using a function objectcomp.The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
set_intersectionto compute the set intersection of sets of integers sorted in descending order using thethrust::hostexecution policy for parallelization:#include <thrust/set_operations.h> #include <thrust/execution_policy.h> ... int A1[6] = {11, 9, 7, 5, 3, 1}; int A2[7] = {13, 8, 5, 3, 2, 1, 1}; int result[3]; int *result_end = thrust::set_intersection(thrust::host, A1, A1 + 6, A2, A2 + 7, result, ::cuda::std::greater<int>()); // result is now {5, 3, 1}
See also
includesSee also
See also
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first1 – The beginning of the first input range.
last1 – The end of the first input range.
first2 – The beginning of the second input range.
last2 – The end of the second input range.
result – The beginning of the output range.
comp – Comparison operator.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator,
InputIterator1andInputIterator2have the samevalue_type,InputIterator1'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator1'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator1'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.InputIterator2 – is a model of Input Iterator,
InputIterator2andInputIterator1have the samevalue_type,InputIterator2'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator2'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator2'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.OutputIterator – is a model of Output Iterator.
- Returns:
The end of the output range.
- Pre:
The ranges
[first1, last1)and[first2, last2)shall be sorted with respect tocomp.- Pre:
The resulting range shall not overlap with either input range.
set_intersection(first1, last1, first2, last2, result, comp)#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename StrictWeakCompare>
OutputIterator thrust::set_intersection( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
- StrictWeakCompare comp,
set_intersectionconstructs a sorted range that is the intersection of sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_intersectionperforms the “intersection” operation from set theory: the output range contains a copy of every element that is contained in both[first1, last1)and[first2, last2). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if a value appearsmtimes in[first1, last1)andntimes in[first2, last2)(wheremmay be zero), then it appearsmin(m,n)times in the output range.set_intersectionis stable, meaning that both elements are copied from the first range rather than the second, and that the relative order of elements in the output range is the same as in the first input range.This version of
set_intersectioncompares elements using a function objectcomp.The following code snippet demonstrates how to use
set_intersectionto compute the set intersection of sets of integers sorted in descending order.#include <thrust/set_operations.h> ... int A1[6] = {11, 9, 7, 5, 3, 1}; int A2[7] = {13, 8, 5, 3, 2, 1, 1}; int result[3]; int *result_end = thrust::set_intersection(A1, A1 + 6, A2, A2 + 7, result, ::cuda::std::greater<int>()); // result is now {5, 3, 1}
See also
includesSee also
See also
See also
See also
See also
- Parameters:
first1 – The beginning of the first input range.
last1 – The end of the first input range.
first2 – The beginning of the second input range.
last2 – The end of the second input range.
result – The beginning of the output range.
comp – Comparison operator.
- Template Parameters:
InputIterator1 – is a model of Input Iterator,
InputIterator1andInputIterator2have the samevalue_type,InputIterator1'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator1'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator1'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.InputIterator2 – is a model of Input Iterator,
InputIterator2andInputIterator1have the samevalue_type,InputIterator2'svalue_typeis a model of LessThan Comparable, the ordering onInputIterator2'svalue_typeis a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator2'svalue_typeis convertible to a type inOutputIterator'sset ofvalue_types.OutputIterator – is a model of Output Iterator.
- Returns:
The end of the output range.
- Pre:
The ranges
[first1, last1)and[first2, last2)shall be sorted with respect tocomp.- Pre:
The resulting range shall not overlap with either input range.