vector size、capacity、reserve 与 resize | STL

本章覆盖:size vs capacity;`reserve`;`resize`;capacity growth;reallocation;default / value initialization;reserve 不改变 size;resize 会改变元素数量;预估数据量时 reserve 的价值;过度 reserve 造成浪费;`shrink_to_fit` 是 non-binding request。

本章知识点

  • size vs capacity
  • reserve
  • resize
  • capacity growth
  • reallocation
  • default / value initialization
  • reserve 不改变 size
  • resize 会改变元素数量
  • 预估数据量时 reserve 的价值
  • 过度 reserve 造成浪费
  • shrink_to_fit 是 non-binding request