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






Demonstrating the STL list unique functions

  
 

#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
 */       
    
  








Related examples in the same category

1.Remove duplicates
2.Removing Duplicates from Lists