#include<bits/stdc++.h>
using namespace std;
int main(){
const int n=5;
int a[n]={1,2,2,4,4};
multiset<int> s(a,a+n); //多重集
//set 不支持迭代器相减 iterator1-iterator
/*
for(int i=0;i<n;i++)
printf("%d ",s[i]); 无效表达
*/
printf("elements in set:\n");//输出集合中元素
copy(s.begin(),s.end(),ostream_iterator<int>(cout," "));
cout<<endl;
//容器大小
printf("size of set = %d\n",s.size());
int x=10;
//查找元素是否存在
set<int>::iterator i = s.find(x); //寻找集合中是否存在元素4,若存在返回其iterator,否则返回
if(i!=s.end())
printf("exist the element %d\n",*i);
else
printf("not found %d!\n",x);
//统计元素个数
int cnt=s.count(4); //统计4的个数
printf("count of 4 = %d\n",cnt);
//二分查找元素
i=s.lower_bound(2);
printf("lower_bound = %d\n",*i); //返回 2
i=s.upper_bound(2);
printf("upper_bound = %d\n",*i);//返回 4
}