cuda::experimental::stf::unstable_unique

Defined in include/cuda/experimental/__stf/utility/unstable_unique.cuh

template<class iterator, class BinaryPredicate>
iterator cuda::experimental::stf::unstable_unique(iterator first, iterator last, BinaryPredicate p)

Removes duplicates from a range using a custom predicate.

This function operates from both sides of the range, moving elements from the right-hand side to the left to eliminate duplicates. The order of the elements is not preserved.

Example:

::std::vector<int> v = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5};
auto new_end = unstable_unique(v.begin(), v.end(), [](int a, int b) { return a == b; });
v.erase(new_end, v.end());
// v is now {1, 5, 2, 4, 3, 5}

Template Parameters
  • iterator – The type of the iterator.

  • BinaryPredicate – The type of the predicate.

Parameters
  • first, last – The range of elements to remove duplicates from.

  • p – The predicate to use for comparing elements.

Returns

iterator The new end of the range after duplicates have been removed.