Delete all adjacent duplicate elements.
vector<>::iterator end_unique = words.erase(end_unique, words.end());
#include <iostream> #include <cassert> #include <algorithm> #include <vector> #include <> #include <iterator> //cout<<<< N= array1[N]={,,,,,,,,,, vector<> ( i=;i<N;++ vector<> new_end= assert(vector1.size()== copy(vector1.begin(),vector1.end(),ostream_iterator<>(cout, cout<< }
The running result is:
The former accepts the real parameters of the third iterator and is used to specify the target sequence for copying non-repeating elements.
Unique_copy literally removes duplicate elements and then performs the copy operation.
#include<iostream> #include<list> #include<vector> #include<algorithm> ia[] = { , , , , , , list<> ilst(ia , ia + vector<> ilst.sort(); cout<<<< (vector<>::iterator iter = ivec.begin() ; iter != ivec.end() ; ++ cout<<*iter<< cout<< }
Assume that
list<> ilst(ia , ia + <> ilst(ia , ia + );
The sorting is available:
sort(ilst.begin() , ilst.end());
Pay attention to the sorting method of list and vector.
partial_sort。