Efficiency Issues

Although it is convenient to grow a vector on demand with push_back, it is also very inefficient.

To store all the data in a given vector, a contiguous block of memory must be allocated. Therefore each time the size of a vector is increased by one with push_back, a contiguous block of memory must first be found and the values of all the elements must be copied to this larger block of memory.

If one already knows the number of element needed in a vector, then one should specify that size when the vector is declared, and then fill it.