时间复杂度:
| map | unordered_map | |
|---|---|---|
| Ordering | increasing order | no order |
| Implementation | Self balancing BST | Hash Table |
| search time | log(n) | O(1): 平均水ping O(n):最糟糕情况 |
| Insertion time | log(n) + Rebalance | Same sa search |
| Delete time | log(n) + Rebalance | Same sa search |
参考资料
1. C++面试常见题目7_STL之map与unordered_map(红黑树VS哈希表)
2. c++ STL容器map和unordered_map有什么区别