Why is vector array doubled?

前端 未结 7 1746
北恋
北恋 2020-12-02 21:27

Why does the classic implementation of Vector (ArrayList for Java people) double its internal array size on each expansion instead of tripling or quadrupling it?

7条回答
  •  醉梦人生
    2020-12-02 21:41

    There is no performance reason for doubling vs tripling or quadrupling as the all have the same big O performance profiles. However in absolute terms doubling will tend to be more space efficient in the normal scenario.

提交回复
热议问题