unique_by_key_copy
#
Overloads#
unique_by_key_copy(exec, keys_first, keys_last, values_first, keys_result, values_result)
#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator1, typename OutputIterator2>
thrust::pair<OutputIterator1, OutputIterator2> thrust::unique_by_key_copy( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 keys_first,
- InputIterator1 keys_last,
- InputIterator2 values_first,
- OutputIterator1 keys_result,
- OutputIterator2 values_result,
unique_by_key_copy
is a generalization ofunique_copy
to key-value pairs. For each group of consecutive keys in the range[keys_first, keys_last)
that are equal,unique_by_key_copy
copies the first element of the group to a range beginning withkeys_result
and the corresponding values from the range[values_first, values_first + (keys_last - keys_first))
are copied to a range beginning withvalues_result
.This version of
unique_by_key_copy
usesoperator==
to test for equality andproject1st
to reduce values with equal keys.The algorithm’s execution is parallelized as determined by
exec
.The following code snippet demonstrates how to use
unique_by_key_copy
to compact a sequence of key/value pairs and with equal keys using thethrust::host
execution policy for parallelization:#include <thrust/unique.h> #include <thrust/execution_policy.h> ... const int N = 7; int A[N] = {1, 3, 3, 3, 2, 2, 1}; // input keys int B[N] = {9, 8, 7, 6, 5, 4, 3}; // input values int C[N]; // output keys int D[N]; // output values thrust::pair<int*,int*> new_end; new_end = thrust::unique_by_key_copy(thrust::host, A, A + N, B, C, D); // The first four keys in C are now {1, 3, 2, 1} and new_end.first - C is 4. // The first four values in D are now {9, 8, 5, 3} and new_end.second - D is 4.
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
keys_first – The beginning of the input key range.
keys_last – The end of the input key range.
values_first – The beginning of the input value range.
keys_result – The beginning of the output key range.
values_result – The beginning of the output value range.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator,
InputIterator2 – is a model of Input Iterator,
OutputIterator1 – is a model of Output Iterator and and
InputIterator1's
value_type
is convertible toOutputIterator1's
value_type
.OutputIterator2 – is a model of Output Iterator and and
InputIterator2's
value_type
is convertible toOutputIterator2's
value_type
.
- Returns:
A pair of iterators at end of the ranges
[keys_result, keys_result_last)
and[values_result, values_result_last)
.- Pre:
The input ranges shall not overlap either output range.
unique_by_key_copy(keys_first, keys_last, values_first, keys_result, values_result)
#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator1, typename OutputIterator2>
thrust::pair<OutputIterator1, OutputIterator2> thrust::unique_by_key_copy( - InputIterator1 keys_first,
- InputIterator1 keys_last,
- InputIterator2 values_first,
- OutputIterator1 keys_result,
- OutputIterator2 values_result,
unique_by_key_copy
is a generalization ofunique_copy
to key-value pairs. For each group of consecutive keys in the range[keys_first, keys_last)
that are equal,unique_by_key_copy
copies the first element of the group to a range beginning withkeys_result
and the corresponding values from the range[values_first, values_first + (keys_last - keys_first))
are copied to a range beginning withvalues_result
.This version of
unique_by_key_copy
usesoperator==
to test for equality andproject1st
to reduce values with equal keys.The following code snippet demonstrates how to use
unique_by_key_copy
to compact a sequence of key/value pairs and with equal keys.#include <thrust/unique.h> ... const int N = 7; int A[N] = {1, 3, 3, 3, 2, 2, 1}; // input keys int B[N] = {9, 8, 7, 6, 5, 4, 3}; // input values int C[N]; // output keys int D[N]; // output values thrust::pair<int*,int*> new_end; new_end = thrust::unique_by_key_copy(A, A + N, B, C, D); // The first four keys in C are now {1, 3, 2, 1} and new_end.first - C is 4. // The first four values in D are now {9, 8, 5, 3} and new_end.second - D is 4.
See also
See also
See also
- Parameters:
keys_first – The beginning of the input key range.
keys_last – The end of the input key range.
values_first – The beginning of the input value range.
keys_result – The beginning of the output key range.
values_result – The beginning of the output value range.
- Template Parameters:
InputIterator1 – is a model of Input Iterator,
InputIterator2 – is a model of Input Iterator,
OutputIterator1 – is a model of Output Iterator and and
InputIterator1's
value_type
is convertible toOutputIterator1's
value_type
.OutputIterator2 – is a model of Output Iterator and and
InputIterator2's
value_type
is convertible toOutputIterator2's
value_type
.
- Returns:
A pair of iterators at end of the ranges
[keys_result, keys_result_last)
and[values_result, values_result_last)
.- Pre:
The input ranges shall not overlap either output range.
unique_by_key_copy(exec, keys_first, keys_last, values_first, keys_result, values_result, binary_pred)
#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator1, typename OutputIterator2, typename BinaryPredicate>
thrust::pair<OutputIterator1, OutputIterator2> thrust::unique_by_key_copy( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 keys_first,
- InputIterator1 keys_last,
- InputIterator2 values_first,
- OutputIterator1 keys_result,
- OutputIterator2 values_result,
- BinaryPredicate binary_pred,
unique_by_key_copy
is a generalization ofunique_copy
to key-value pairs. For each group of consecutive keys in the range[keys_first, keys_last)
that are equal,unique_by_key_copy
copies the first element of the group to a range beginning withkeys_result
and the corresponding values from the range[values_first, values_first + (keys_last - keys_first))
are copied to a range beginning withvalues_result
.This version of
unique_by_key_copy
uses the function objectbinary_pred
to test for equality andproject1st
to reduce values with equal keys.The algorithm’s execution is parallelized as determined by
exec
.The following code snippet demonstrates how to use
unique_by_key_copy
to compact a sequence of key/value pairs and with equal keys using thethrust::host
execution policy for parallelization:#include <thrust/unique.h> #include <thrust/execution_policy.h> ... const int N = 7; int A[N] = {1, 3, 3, 3, 2, 2, 1}; // input keys int B[N] = {9, 8, 7, 6, 5, 4, 3}; // input values int C[N]; // output keys int D[N]; // output values thrust::pair<int*,int*> new_end; ::cuda::std::equal_to<int> binary_pred; new_end = thrust::unique_by_key_copy(thrust::host, A, A + N, B, C, D, binary_pred); // The first four keys in C are now {1, 3, 2, 1} and new_end.first - C is 4. // The first four values in D are now {9, 8, 5, 3} and new_end.second - D is 4.
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
keys_first – The beginning of the input key range.
keys_last – The end of the input key range.
values_first – The beginning of the input value range.
keys_result – The beginning of the output key range.
values_result – The beginning of the output value range.
binary_pred – The binary predicate used to determine equality.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator,
InputIterator2 – is a model of Input Iterator,
OutputIterator1 – is a model of Output Iterator and and
InputIterator1's
value_type
is convertible toOutputIterator1's
value_type
.OutputIterator2 – is a model of Output Iterator and and
InputIterator2's
value_type
is convertible toOutputIterator2's
value_type
.BinaryPredicate – is a model of Binary Predicate.
- Returns:
A pair of iterators at end of the ranges
[keys_result, keys_result_last)
and[values_result, values_result_last)
.- Pre:
The input ranges shall not overlap either output range.
unique_by_key_copy(keys_first, keys_last, values_first, keys_result, values_result, binary_pred)
#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator1, typename OutputIterator2, typename BinaryPredicate>
thrust::pair<OutputIterator1, OutputIterator2> thrust::unique_by_key_copy( - InputIterator1 keys_first,
- InputIterator1 keys_last,
- InputIterator2 values_first,
- OutputIterator1 keys_result,
- OutputIterator2 values_result,
- BinaryPredicate binary_pred,
unique_by_key_copy
is a generalization ofunique_copy
to key-value pairs. For each group of consecutive keys in the range[keys_first, keys_last)
that are equal,unique_by_key_copy
copies the first element of the group to a range beginning withkeys_result
and the corresponding values from the range[values_first, values_first + (keys_last - keys_first))
are copied to a range beginning withvalues_result
.This version of
unique_by_key_copy
uses the function objectbinary_pred
to test for equality andproject1st
to reduce values with equal keys.The following code snippet demonstrates how to use
unique_by_key_copy
to compact a sequence of key/value pairs and with equal keys.#include <thrust/unique.h> ... const int N = 7; int A[N] = {1, 3, 3, 3, 2, 2, 1}; // input keys int B[N] = {9, 8, 7, 6, 5, 4, 3}; // input values int C[N]; // output keys int D[N]; // output values thrust::pair<int*,int*> new_end; ::cuda::std::equal_to<int> binary_pred; new_end = thrust::unique_by_key_copy(A, A + N, B, C, D, binary_pred); // The first four keys in C are now {1, 3, 2, 1} and new_end.first - C is 4. // The first four values in D are now {9, 8, 5, 3} and new_end.second - D is 4.
See also
See also
See also
- Parameters:
keys_first – The beginning of the input key range.
keys_last – The end of the input key range.
values_first – The beginning of the input value range.
keys_result – The beginning of the output key range.
values_result – The beginning of the output value range.
binary_pred – The binary predicate used to determine equality.
- Template Parameters:
InputIterator1 – is a model of Input Iterator,
InputIterator2 – is a model of Input Iterator,
OutputIterator1 – is a model of Output Iterator and and
InputIterator1's
value_type
is convertible toOutputIterator1's
value_type
.OutputIterator2 – is a model of Output Iterator and and
InputIterator2's
value_type
is convertible toOutputIterator2's
value_type
.BinaryPredicate – is a model of Binary Predicate.
- Returns:
A pair of iterators at end of the ranges
[keys_result, keys_result_last)
and[values_result, values_result_last)
.- Pre:
The input ranges shall not overlap either output range.