I'm a bit confused on the best way to do the following:
Say I have the following sorted key value pairs
(K:V) (0 : .5)(0 : .7)(0 : .9) (1 : .2) (1 : .6) (1 : .8)
and so on..
I want to remove copy the minimum value of each key so I'll have 2 results
minimum by key
(0 : .5)(1 : .2)
remaining
(0 : .7)(0 : .9)(1 : .6)(1 : .8)
thrust::unique_by_key_copy would appear to be able to give me the minimum by key since (K:V) is sorted. However I'm not sure how to remove those that are chosen from original to get the remaining.
Any thoughts or advice greatly appreciated
I'm sure there are a number of ways to do this.
One possible approach is to use
thrust::adjacent_difference
to create a "flag array".Then use
thrust::copy_if
(the stencil version) using the flag array (as the stencil) to select first the elements you want in result 1, then the elements you want in result 2 (using the inverse of the flag array, logically).Here's a worked example: