Description: When the number of elements in the array change, do not re-apply for the memory space, the array can continue to use. This will improve efficiency.
Algorithm for the machine, the "time" and "space" of the conflict is always there: a little more storage, running on the faster store less, running on more slowly. Embodied in here, this treatment is a space for time. Although the memory space is "wasted" some of the space, but in a very long time, as long as the space has not changed, run on a constant time complexity. Only when existing space is not enough, the only place to re-apply and release the memory operation. The easiest way is to double the growth, that is multiplied by 2, so the size of memory allocation is a power of 2.
To Search:
File list (Check if you may need any files):
DArray-better\DynamicArray.dsw
.............\DynamicArray.ncb
.............\DynamicArray.plg
.............\DynamicArray.dsp
.............\DArray.h
.............\.ebug\vc60.idb
.............\.....\vc60.pdb
.............\.....\DynamicArray.exe
.............\.....\DynamicArray.pdb
.............\.....\DynamicArray.ilk
.............\.....\DynamicArray.pch
.............\.....\main.obj
.............\.....\DArray.obj
.............\main.cpp
.............\DArray.cpp
.............\DynamicArray.opt
.............\Debug
DArray-better