C++ STL Cheatsheet

Vector

Initiatlisation:

vector<int> a{1,2,3};
vector<int> b(a);
vector<int>> c(2,3); //[2,2,2]
vector<vector<int>> d(vector<int>(0,2),2); // [ [0,0] , [0,0] ]

Methods:

vector<int>::iterator it = vec.begin();
vector<int>::iterator it = vec.end();

int size = vec.size();
vec.push_back( 5 );
vec.erase( it );
int elem = vec[0];

for (auto elem : vec){...}