thrust::set_symmetric_difference#
Overloads#
set_symmetric_difference(exec, first1, last1, first2, last2, result)#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::set_symmetric_difference( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
set_symmetric_differenceconstructs a sorted range that is the set symmetric difference of the sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_symmetric_differenceperforms a set theoretic calculation: it constructs the union of the two sets A - B and B - A, where A and B are the two input ranges. That is, the output range contains a copy of every element that is contained in[first1, last1)but not[first2, last2), and a copy of every element that is contained in[first2, last2)but not[first1, last1). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)containsmelements that are equivalent to each other and[first2, last2)containsnelements that are equivalent to them, then|m - n|of those elements shall be copied to the output range: the lastm - nelements from[first1, last1)ifm > n, and the lastn - mof these elements from[first2, last2)ifm < n.This version of
set_unioncompares elements usingoperator<.The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
set_symmetric_differenceto compute the symmetric difference 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[7] = {0, 1, 2, 2, 4, 6, 7}; int A2[5] = {1, 1, 2, 5, 8}; int result[6]; int *result_end = thrust::set_symmetric_difference(thrust::host, A1, A1 + 7, A2, A2 + 5, result); // result = {0, 4, 5, 6, 7, 8}
See also
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_symmetric_difference(first1, last1, first2, last2, result)#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::set_symmetric_difference( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
set_symmetric_differenceconstructs a sorted range that is the set symmetric difference of the sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_symmetric_differenceperforms a set theoretic calculation: it constructs the union of the two sets A - B and B - A, where A and B are the two input ranges. That is, the output range contains a copy of every element that is contained in[first1, last1)but not[first2, last2), and a copy of every element that is contained in[first2, last2)but not[first1, last1). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)containsmelements that are equivalent to each other and[first2, last2)containsnelements that are equivalent to them, then|m - n|of those elements shall be copied to the output range: the lastm - nelements from[first1, last1)ifm > n, and the lastn - mof these elements from[first2, last2)ifm < n.This version of
set_unioncompares elements usingoperator<.The following code snippet demonstrates how to use
set_symmetric_differenceto compute the symmetric difference of two sets of integers sorted in ascending order.#include <thrust/set_operations.h> ... int A1[7] = {0, 1, 2, 2, 4, 6, 7}; int A2[5] = {1, 1, 2, 5, 8}; int result[6]; int *result_end = thrust::set_symmetric_difference(A1, A1 + 7, A2, A2 + 5, result); // result = {0, 4, 5, 6, 7, 8}
See also
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_symmetric_difference(exec, first1, last1, first2, last2, result, comp)#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename StrictWeakCompare>
OutputIterator thrust::set_symmetric_difference( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
- StrictWeakCompare comp,
set_symmetric_differenceconstructs a sorted range that is the set symmetric difference of the sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_symmetric_differenceperforms a set theoretic calculation: it constructs the union of the two sets A - B and B - A, where A and B are the two input ranges. That is, the output range contains a copy of every element that is contained in[first1, last1)but not[first2, last2), and a copy of every element that is contained in[first2, last2)but not[first1, last1). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)containsmelements that are equivalent to each other and[first2, last2)containsnelements that are equivalent to them, then|m - n|of those elements shall be copied to the output range: the lastm - nelements from[first1, last1)ifm > n, and the lastn - mof these elements from[first2, last2)ifm < n.This version of
set_unioncompares elements using a function objectcomp.The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
set_symmetric_differenceto compute the symmetric difference of two 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[7] = {7, 6, 4, 2, 2, 1, 0}; int A2[5] = {8, 5, 2, 1, 1}; int result[6]; int *result_end = thrust::set_symmetric_difference(thrust::host, A1, A1 + 7, A2, A2 + 5, result); // result = {8, 7, 6, 5, 4, 0}
See also
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_symmetric_difference(first1, last1, first2, last2, result, comp)#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename StrictWeakCompare>
OutputIterator thrust::set_symmetric_difference( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
- StrictWeakCompare comp,
set_symmetric_differenceconstructs a sorted range that is the set symmetric difference of the sorted ranges[first1, last1)and[first2, last2). The return value is the end of the output range.In the simplest case,
set_symmetric_differenceperforms a set theoretic calculation: it constructs the union of the two sets A - B and B - A, where A and B are the two input ranges. That is, the output range contains a copy of every element that is contained in[first1, last1)but not[first2, last2), and a copy of every element that is contained in[first2, last2)but not[first1, last1). The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)containsmelements that are equivalent to each other and[first2, last2)containsnelements that are equivalent to them, then|m - n|of those elements shall be copied to the output range: the lastm - nelements from[first1, last1)ifm > n, and the lastn - mof these elements from[first2, last2)ifm < n.This version of
set_unioncompares elements using a function objectcomp.The following code snippet demonstrates how to use
set_symmetric_differenceto compute the symmetric difference of two sets of integers sorted in descending order.#include <thrust/set_operations.h> ... int A1[7] = {7, 6, 4, 2, 2, 1, 0}; int A2[5] = {8, 5, 2, 1, 1}; int result[6]; int *result_end = thrust::set_symmetric_difference(A1, A1 + 7, A2, A2 + 5, result); // result = {8, 7, 6, 5, 4, 0}
See also
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.