#include <iostream>
#include <list>
using namespace std;
int main()
{
list<int> listObject;
list<int>::iterator p;
for(int i = 0; i < 5; i++)
for(int j = 0; j < 3; j++)
listObject.push_back(i);
cout << "Orignal list: ";
for(p = listObject.begin(); p != listObject.end(); p++)
cout << *p << " ";
cout << endl;
listObject.unique(); // remove consecutive duplicates
cout << "Modified list: ";
for(p = listObject.begin(); p != listObject.end(); p++)
cout << *p << " ";
cout << endl;
return 0;
}
|