multiset
可重复元素的\(set\)。
定义:
struct nd{
int x;
friend bool operator ()(nd x,nd y){return x.x < y.x;}//可自定义比较
};
multiset<nd> tree;
操作:
auto it = tree.begin() //返回第一个元素的迭代器
int c = *it; //可用于求值
auto it = tree.find(x) // 返回某一元素的位置
int c = tree.erase(x) //删除与x相等的所有元素,返回被移除的元素个数
tree.erase(it) //移除迭代器it所指位置元素,无返回值
int c = tree.insert(x) //插入一个x,返回新元素位置