時間復雜度:
? | 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有什么區別