I have a pair of arrays of equal size, I will call them keys and values. For example: K: V 1: 99 1: 100 1: 100 1: 100 1: 103 2: 103 2: 105 3: 45 3: 67 The keys are sorted and the values associated with each key are sorted. How do I remove the value duplicates associated with each key and its corresponding key? That is, I want to compact the above to: 1: 99 1: 100 1: 103 2: 103 <-- This should remain, since key is different 2: 105 3: 45 3: 67 I looked at the stream compaction functions available in Thrust , but was not able to find anything which does this. Is this possible with Thrust? Or do I