📜  c++ vector 组合两个向量 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:45.803000             🧑  作者: Mango

代码示例3
// my linkedin : https://www.linkedin.com/in/vaalarivan-prasanna-3a07bb203/
vector AB;
AB.reserve(A.size() + B.size()); // preallocate memory
AB.insert(AB.end(), A.begin(), A.end());
AB.insert(AB.end(), B.begin(), B.end());
//eg : A = {4, 1}, B = {2, 5}
//after the 2 insert operations, AB = {4, 1, 2, 5}