Pushing a vector into an vector
Posted
by
Sunil
on Stack Overflow
See other posts from Stack Overflow
or by Sunil
Published on 2010-12-29T23:41:33Z
Indexed on
2010/12/29
23:54 UTC
Read the original article
Hit count: 241
I have a 2d vector
typedef vector <double> record_t;
typedef vector <record_t> data_t;
data_t data;
So my 2d vector is data
here. It has elements like say,
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
Now I want to insert these elements into another 2d vector
std::vector< vector<double> > window;
So what I did was to create an iterator for traversing through the rows of data
and pushing it into window
like
std::vector< std::vector<double> >::iterator data_it;
for (data_it = data.begin() ; data_it != data.end() ; ++data_it)
window.push_back ( *data_it );
Can anybody tell me where I'm wrong or suggest a way to do this ?
Thanks
© Stack Overflow or respective owner