////////////////////////////////////////
// 2018/04/28 9:02:40
// set-clear
// removes all elements
#include <iostream>
#include <set>
#include <functional>
using namespace std;
void print(set<int, less<int>>& s){
set<int, less<int>>::iterator it;
for (it = s.begin(); it != s.end(); it++){
cout << *it << " ";
}
cout << endl;
}
//-------------------------
int main(){
int ary[] = { 1, 2, 3, 2, 3, 4, 8, 2, 5, 6 };
set<int, less<int>> s;
s.insert(ary, ary + 10);
print(s);
s.clear();
cout << "size of set s = " << s.size() << endl;
print(s);
return 0;
}
/*
OUTPUT:
1 2 3 4 5 6 8
size of set s = 0
此行为空
*/