vector的每日默写
作者:
George
,
2020-12-04 19:28:02
,
所有人可见
,
阅读 580
iterator
*(ans.begin()+i) == a[i]
声明及初始化
vector<int> ans;
vector<int> ans(length);
vector<int> ans(length, default_value);
vector<vector<int>> ans;
vector<vector<int>> ans(row, vector<int>(col);
vector<vector<int>> ans(row, vector<int>(col, default_value);
CRUD
ans.push_back(value);
if(i < ans.size()) ans[i] = value;
ans.pop_back()
if(i < ans.size() ans.erase(ans.begin()+i);
if(i+length < ans.size() ans.erase(ans.begin()+i, ans.begin()+i+length);
if(i < ans.size()) value = ans[i]
ans.back();
ans.front();
针对值
find(ans.begin(), ans.end(), value);