Hi guys.
Can anyone give me a rough idea of how to remove duplicate items from a vector?
Printable View
Hi guys.
Can anyone give me a rough idea of how to remove duplicate items from a vector?
Use a std::set instead of a std::vector.
There's also an std::unique() function that does just what you're looking for (I believe you'd need to also use the std::vector::erase() function afterwards).
If your vector is sorted, or if sorting it is an option, then indeed std::unique with the range version of member function erase() would be a very good option.