unique - a function that compresses all sequences of identical consecutive elements into one in linear time.
As an argument, it is passed the boundaries of the array, within which it is necessary to apply compression.
An iterator is returned to the new end (not inclusive) of the array. You should be careful with elements after the new end but before the old one, as they will have an undefined value.
You can read more in documentation.
If you're using this function on a vector, it's convenient to resize using the returned result (more on that below).
Examples:
vector a = { 3, 3, 3, 2, 3, 3, 1, 1, 4, 5, 5 };
unique(a.begin(), a.end());
// a = [3, 2, 3, 1, 4, 5, ?, ?, ?, ?, ?]
// using the unique function is convenient to do
// auxiliary array for coordinate compression
a = { 235, 10, 41, 10, 41, 41, 235, 500, 500 };
sort(a.begin(), a.end());
// a = [10, 10, 41, 41, 41, 235, 235, 500, 500]
a.resize(unique(a.begin(), a.end()) - a.begin());
// a = [10, 41, 235, 500]