T
toton
Hi,
I want to append one vector after another.
so like,
vector<int> v1; ///put some elements to v2.
I have a second vector
vector<int> v2; ///it has some elements.
Now I do
v1.reserve(v1.size() + v2.size()) ;
and then
vector<int>::const_iterator begin = v2.begin();
vector<int>::const_iterator end = v2.end();
for( ; begin!=end; ++begin){
v1.push_back(*begin);
}
Is there any better way to do it?
Similarly I need to do pop_front from a deque a number of elements. So
using pop_front in a loop is the best way?
I want to append one vector after another.
so like,
vector<int> v1; ///put some elements to v2.
I have a second vector
vector<int> v2; ///it has some elements.
Now I do
v1.reserve(v1.size() + v2.size()) ;
and then
vector<int>::const_iterator begin = v2.begin();
vector<int>::const_iterator end = v2.end();
for( ; begin!=end; ++begin){
v1.push_back(*begin);
}
Is there any better way to do it?
Similarly I need to do pop_front from a deque a number of elements. So
using pop_front in a loop is the best way?