【发布时间】:2021-01-15 23:50:01
【问题描述】:
int main(){
unordered_set<int> S;
S.insert(1);
S.insert(10);
S.insert(100);
S.insert(64);
for(auto &x: S){
cout<<x<<" ";
}
cout<<endl;
S.erase(S.find(1),S.end());
for(auto &x: S){
cout<<x<<" ";
}
}
输出:
64 1 100 10
64
这对于每个 IDE 和每次都是一样的。
unordered_set 不使用哈希吗?
而且哈希没有顺序。
【问题讨论】:
-
IDE 对此一无所知。这是由编译器提供的标准库实现的结果。例如,您会看到 clang 和 msvc 的不同结果。
标签: c++ hash stl unordered-set