完全删除向量 c++
我在从“多维向量”中删除向量时遇到问题
我想实现这一点:
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());
似乎使用向量.erase()或向量.clear()在“第三行”留下一个空向量 有没有办法完全删除该向量,以便
vec[3]=4 4 4 4
感谢一个伟大的论坛...... /布克斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下行删除 vec 的第三个元素。如果它有四个元素,则该行执行后将有三个。
另一方面,下面的行将使第三个向量为空。
The following line removes the third element of
vec
. If it had four elements, it will have three after the line is executed.The following line, on the other hand, will leave the third vector empty.