#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <set>
#include <iterator>
using namespace std;
int main()
{
typedef set<double > double_set;//等价于typedef set<double,less<double> > double_set;
const int SIZE=5;
double a[SIZE]={2.1, 4.2, 9.5, 2.1, 3.7};
double_set doubleSet(a,a+SIZE);
ostream_iterator<double> output(cout," ");
cout<<"1)";
copy(doubleSet.begin(),doubleSet.end(),output);
cout<<endl;
pair<double_set::const_iterator,bool> p;
p=doubleSet.insert(9.5); //insert()函数返回值是一个pair对象,其first是被插入元素的迭代器,
//second代表是否成功插入了
//因为插入的是9.5,而9.5 set容器早已含有,所以插入不成功
if(p.second)
cout<<"2)"<<*(p.first)<<" inserted"<<endl;
else
cout<<"2)"<<*p.first<<" not inserted"<<endl; //*p.first等价于*(p.first)
return 0;
}