Vector growth factor in languages

Growth factor is the factor by which the new size of a C++ STL vector is computed when we need to insert beyond its current capacity. There are containers similar to the STL vector in other languages and it is quite interesting to see what factors were chosen in those implementations.

  • The last time I looked into this (see this post), VC++ vector had a growth factor of 1.5 and GCC vector had a growth factor of 2.

  • Java ArrayList seems to have a growth factor of 1.5. See line 240 in ArrayList.java.

  • Julia also seems to have a growth factor of 1.5.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.