无序关联容器
#include <unordered_set>
#include <unordered_map>

有序关联容器 => 底层是红黑树结构  
#include<set>
#include<map>
set<int> set1 ;//不允许重复
for(int i=0;i<100;i++){
     set1.insert(rand()%100+1);
}

//默认是红黑树中序遍历,默认会从小到大排序输出 
for(int v :set1){
    cout<<v<<endl;
}

当我们使用有序集合的时候,放入自定义类型的时候例如student类,因为容器是有序的
那么按什么规则做比较呢?我们需要重写 bool operater<() const 方法

class student{

public:
   bool operator<(const student & stu)const {
        return this.id<stu.id;
   }
private:
    int id;
    string name;
}


multiset<int> mset1 ;//允许重复


class student{

public:
   bool operator<(const student & stu)const {
        return this.id<stu.id;
   }
private:
    int id;
    string name;
}

map<int ,student> stuMap;
stuMap.insert(100,student(100,"AAA"));
stuMap.insert(101,student(101,"BBB"));
stuMap.insert(102,student(102,"CCC"));

stuMap.erase(iterator);//删除元素
stuMap.erase(101);     //删除元素

cout<<stuMap[1000]<<endl;//这种查询方式有副作用,当key不存在是,会插入当前的key 和一个默认的value
当前情况下不需要student 重写 bool operator<() 方法了,因为 map 使用key来排序


auto it1=stuMap.begin();

for(;it1!=stuMap.end();++it1){
   
   cout<<it1->first<<" "<<it1->second<<endl;

}