STLPractice

vector

Initialization

// create empty vector 
vector<int> vect; 

// create a vector with n size & all value is 10
vector<int> vect(n, 10); 

// initialization list
vector<int> vect{ 10, 20, 30 }; 

// use list
int arr[] = { 10, 20, 30 }; 
int n = sizeof(arr) / sizeof(arr[0]); 
vector<int> vect(arr, arr + n); 

vector<int> vect1{ 10, 20, 30 }; 
vector<int> vect2(vect1.begin(), vect1.end());

通用

容器的遍历

swap elements

最后更新于