cuda::experimental::stf::unstable_unique
#
Overloads#
unstable_unique(first, last, p)
#
-
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.
unstable_unique(first, last)
#
-
template<class iterator>
iterator cuda::experimental::stf::unstable_unique(
) Removes duplicates from a range using the built-in operator==.
This function operates like
unstable_unique
above withoperator==
as the predicate.- Example:
::std::vector<int> v = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5}; auto new_end = unstable_unique(v.begin(), v.end()); v.erase(new_end, v.end()); // v is now {1, 5, 2, 4, 3, 5}
- Template Parameters:
iterator – The type of the iterator.
- Parameters:
first, last – The range of elements to remove duplicates from.
- Returns:
iterator The new end of the range after duplicates have been removed.