set_union
#
Overloads#
set_union(exec, first1, last1, first2, last2, result)
#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::set_union( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
set_union
constructs a sorted range that is the union of the sorted ranges[first1, last1)
and[first2, last2)
. The return value is the end of the output range.In the simplest case,
set_union
performs the “union” operation from set theory: the output range contains a copy of every element that is contained in[first1, last1)
,[first2, last2)
, or both. The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)
containsm
elements that are equivalent to each other and if[first2, last2)
containsn
elements that are equivalent to them, then allm
elements from the first range shall be copied to the output range, in order, and thenmax(n - m, 0)
elements from the second range shall be copied to the output, in order.This version of
set_union
compares elements usingoperator<
.The algorithm’s execution is parallelized as determined by
exec
.The following code snippet demonstrates how to use
set_union
to compute the union of two sets of integers sorted in ascending order using thethrust::host
execution policy for parallelization:#include <thrust/set_operations.h> #include <thrust/execution_policy.h> ... int A1[7] = {0, 2, 4, 6, 8, 10, 12}; int A2[5] = {1, 3, 5, 7, 9}; int result[11]; int *result_end = thrust::set_union(thrust::host, A1, A1 + 7, A2, A2 + 5, result); // result = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12}
See also
See also
includes
See 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,
InputIterator1
andInputIterator2
have the samevalue_type
,InputIterator1's
value_type
is a model of LessThan Comparable, the ordering onInputIterator1's
value_type
is a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator1's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.InputIterator2 – is a model of Input Iterator,
InputIterator2
andInputIterator1
have the samevalue_type
,InputIterator2's
value_type
is a model of LessThan Comparable, the ordering onInputIterator2's
value_type
is a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator2's
value_type
is convertible to a type inOutputIterator's
set 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_union(first1, last1, first2, last2, result)
#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::set_union( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
set_union
constructs a sorted range that is the union of the sorted ranges[first1, last1)
and[first2, last2)
. The return value is the end of the output range.In the simplest case,
set_union
performs the “union” operation from set theory: the output range contains a copy of every element that is contained in[first1, last1)
,[first2, last2)
, or both. The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)
containsm
elements that are equivalent to each other and if[first2, last2)
containsn
elements that are equivalent to them, then allm
elements from the first range shall be copied to the output range, in order, and thenmax(n - m, 0)
elements from the second range shall be copied to the output, in order.This version of
set_union
compares elements usingoperator<
.The following code snippet demonstrates how to use
set_union
to compute the union of two sets of integers sorted in ascending order.#include <thrust/set_operations.h> ... int A1[7] = {0, 2, 4, 6, 8, 10, 12}; int A2[5] = {1, 3, 5, 7, 9}; int result[11]; int *result_end = thrust::set_union(A1, A1 + 7, A2, A2 + 5, result); // result = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12}
See also
See also
includes
See 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,
InputIterator1
andInputIterator2
have the samevalue_type
,InputIterator1's
value_type
is a model of LessThan Comparable, the ordering onInputIterator1's
value_type
is a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator1's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.InputIterator2 – is a model of Input Iterator,
InputIterator2
andInputIterator1
have the samevalue_type
,InputIterator2's
value_type
is a model of LessThan Comparable, the ordering onInputIterator2's
value_type
is a strict weak ordering, as defined in the LessThan Comparable requirements, andInputIterator2's
value_type
is convertible to a type inOutputIterator's
set 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_union(exec, first1, last1, first2, last2, result, comp)
#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename StrictWeakCompare>
OutputIterator thrust::set_union( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
- StrictWeakCompare comp,
set_union
constructs a sorted range that is the union of the sorted ranges[first1, last1)
and[first2, last2)
. The return value is the end of the output range.In the simplest case,
set_union
performs the “union” operation from set theory: the output range contains a copy of every element that is contained in[first1, last1)
,[first2, last2)
, or both. The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)
containsm
elements that are equivalent to each other and if[first2, last2)
containsn
elements that are equivalent to them, then allm
elements from the first range shall be copied to the output range, in order, and thenmax(n - m, 0)
elements from the second range shall be copied to the output, in order.This version of
set_union
compares elements using a function objectcomp
.The algorithm’s execution is parallelized as determined by
exec
.The following code snippet demonstrates how to use
set_union
to compute the union of two sets of integers sorted in ascending order using thethrust::host
execution policy for parallelization:#include <thrust/set_operations.h> #include <thrust/functional.h> #include <thrust/execution_policy.h> ... int A1[7] = {12, 10, 8, 6, 4, 2, 0}; int A2[5] = {9, 7, 5, 3, 1}; int result[11]; int *result_end = thrust::set_union(thrust::host, A1, A1 + 7, A2, A2 + 5, result, ::cuda::std::greater<int>()); // result = {12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
See also
See also
includes
See 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,
InputIterator1's
value_type
is convertible toStrictWeakCompare's
first argument type. andInputIterator1's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.InputIterator2 – is a model of Input Iterator,
InputIterator2's
value_type
is convertible toStrictWeakCompare's
second argument type. andInputIterator2's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.OutputIterator – is a model of Output Iterator.
StrictWeakCompare – is a model of Strict Weak Ordering.
- 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_union(first1, last1, first2, last2, result, comp)
#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename StrictWeakCompare>
OutputIterator thrust::set_union( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- InputIterator2 last2,
- OutputIterator result,
- StrictWeakCompare comp,
set_union
constructs a sorted range that is the union of the sorted ranges[first1, last1)
and[first2, last2)
. The return value is the end of the output range.In the simplest case,
set_union
performs the “union” operation from set theory: the output range contains a copy of every element that is contained in[first1, last1)
,[first2, last2)
, or both. The general case is more complicated, because the input ranges may contain duplicate elements. The generalization is that if[first1, last1)
containsm
elements that are equivalent to each other and if[first2, last2)
containsn
elements that are equivalent to them, then allm
elements from the first range shall be copied to the output range, in order, and thenmax(n - m, 0)
elements from the second range shall be copied to the output, in order.This version of
set_union
compares elements using a function objectcomp
.The following code snippet demonstrates how to use
set_union
to compute the union of two sets of integers sorted in ascending order.#include <thrust/set_operations.h> #include <thrust/functional.h> ... int A1[7] = {12, 10, 8, 6, 4, 2, 0}; int A2[5] = {9, 7, 5, 3, 1}; int result[11]; int *result_end = thrust::set_union(A1, A1 + 7, A2, A2 + 5, result, ::cuda::std::greater<int>()); // result = {12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
See also
See also
includes
See 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,
InputIterator1's
value_type
is convertible toStrictWeakCompare's
first argument type. andInputIterator1's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.InputIterator2 – is a model of Input Iterator,
InputIterator2's
value_type
is convertible toStrictWeakCompare's
second argument type. andInputIterator2's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.OutputIterator – is a model of Output Iterator.
StrictWeakCompare – is a model of Strict Weak Ordering.
- 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.