vector internal Implementation
vector allocates memory on heap
vector start with 0 capacity, 0 size
Allocate a single element on the first push_back()
vector starts with 0 size and reallocates double or 1.5 times based on
standard library implementations
std::vector<int> a; // Capacity: 0, Size: 0
a.push_back(10); // Allocates capacity 1. Size: 1, Capacity: 1
a.push_back(20); // Reallocates! Size: 2, Capacity: 2
a.push_back(30); // Reallocates! Size: 3, Capacity: 4
| 10 | 20 | 30 | empty |
/\ /\ /\
*start *end *finish
size capacity