Reputation:
I'm having problems removing a vector from a "multidimensional vector"
I would like to achieve this:
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
3 3 3 3 4 4 4 4
4 4 4 4
for example
vector<vector<int>>vec;
for i...//give vec values...
vec[3].erase(vec.begin(),vec.end());
It seems like using vector.erase() or vector.clear() leaves an empty vector at the "third row" Is there a way to completetly remove that vector so that
vec[3]=4 4 4 4
Thanx for a great forum... /Bux
Upvotes: 0
Views: 820
Reputation: 32635
The following line removes the third element of vec
. If it had four elements, it will have three after the line is executed.
vec.erase(vec.begin() + 2);
The following line, on the other hand, will leave the third vector empty.
vec[2].clear();
Upvotes: 4