Standard Guarantee 与 Implementation Detail | STL

本章覆盖:标准规定接口语义与复杂度要求;implementation freedom;vector 连续存储是标准保证;map 必须满足有序关联语义和复杂度,但标准不写死“必须红黑树”;unordered_map 具有 bucket interface 与平均复杂度要求,常见实现为哈希表;deque 的具体 block 大小不由标准固定;small vector 不是 std::vector 标准能力;libstdc++ / libc++ / MSVC STL 实现差异;面试时要明确“标准要求”和“主流实现”。

本章知识点

  • 标准规定接口语义与复杂度要求
  • implementation freedom
  • vector 连续存储是标准保证
  • map 必须满足有序关联语义和复杂度,但标准不写死“必须红黑树”
  • unordered_map 具有 bucket interface 与平均复杂度要求,常见实现为哈希表
  • deque 的具体 block 大小不由标准固定
  • small vector 不是 std::vector 标准能力
  • libstdc++ / libc++ / MSVC STL 实现差异
  • 面试时要明确“标准要求”和“主流实现”