Remove duplicates from consecutive groups of equal int s. Remove all duplicates from a vector of char s, ignoring case. First sort the vector, then remove duplicates from consecutive groups.Example
vector
V.push_back(1);
V.push_back(3);
V.push_back(3);
V.push_back(3);
V.push_back(2);
V.push_back(2);
V.push_back(1);
vector
copy(V.begin(), new_end, ostream_iterator
// The output it "1 3 2 1".
inline bool eq_nocase(char c1, char c2) { return tolower(c1) == tolower(c2); }
inline bool lt_nocase(char c1, char c2) { return tolower(c1) < tolower(c2); }
int main() {
const char init[] = "The Standard Template Library";
vector
sort(V.begin(), V.end(), lt_nocase);
copy(V.begin(), V.end(), ostream_iterator
cout << endl;
vector
copy(V.begin(), new_end, ostream_iterator
cout << endl;
}
// The output is:
// aaaabddeeehiLlmnprrrStTtTy
// abdehiLmnprSty