Demonstrating the STL list unique functions : list unique « list « C++ Tutorial






#include <iostream>
#include <cassert>
#include <string>
#include <list>
using namespace std;

int main()
{
  string s("Stroustrup");

  list<char> list1(s.begin(), s.end());

  list1.sort();
  list1.unique();

  list<char>::iterator i;

  for (i = list1.begin(); i != list1.end(); ++i)
    cout << *i;


  return 0;
}
Soprstu"








17.17.list unique
17.17.1.Demonstrating the STL list unique functions
17.17.2.Remove duplicates from list with unique()
17.17.3.Remove duplicates