16
//m1元素:4 8 19 22 22 33 40
MSET1::iterator pp = m1.find(19);
if( pp != m1.end() ) //条件为真说明找到
cout << "found" << endl;
//本行会被执行,输出 found
cout << "3) "; cout << * m1.lower_bound(22) << ","
<<* m1.upper_bound(22)<< endl;
//输出 3) 22,33
pp = m1.erase(m1.lower_bound(22),m1.upper_bound(22));
//pp指向被删元素的下一个元素
cout << "4) "; Print(m1.begin(),m1.end()); //输出 4) 4 8 19 33 40
cout << "5) "; cout << * pp << endl; //输出 5) 33
MSET2 m2; // m2里的元素按n的个位数从小到大排
m2.insert(a,a+SIZE);
cout << "6) "; Print(m2.begin(),m2.end()); //输出 6) 40 22 33 4 8 19
return 0;
}
iterator lower_bound(const T & val);
查找一个最大的位置 it,使得[begin(),it) 中所有的元素都比 val 小。