I hope this is not a duplicate question, but if it is, feel free to point me in the right direction.
I have a vector.
Is i
Yes, as long as your vector is sorted. See unique () STL documentation for details.
Here is an example of usage:
#include
#include
#include
#include
#include
using namespace std;
int main ()
{
vector< vector > v;
v.push_back (vector ());
v.back ().push_back ("A");
v.push_back (vector ());
v.back ().push_back ("A");
v.push_back (vector ());
v.back ().push_back ("B");
for (vector< vector >::iterator it = v.begin (); it != v.end (); ++it)
for (vector::iterator j = it->begin (), j_end = it->end (); j != j_end; ++j)
cout << *j << endl;
cout << "-------" << endl;
vector< vector >::iterator new_end = unique (v.begin (), v.end ());
for (vector< vector >::iterator it = v.begin (); it != new_end; ++it)
for (vector::iterator j = it->begin (), j_end = it->end (); j != j_end; ++j)
cout << *j << endl;
}