C 98,向量,删除除第一个元素以外的每个元素
c++ 98, vector, remove every element except the first one
arr!这就是我这样做的方式,但是有点长。还有更紧凑的吗?(我正在使用CPP 98!(
std::vector<Object> allObjs;
// ... allObjs gets filled ...
// Now get back a vector with only the first element in allObjs
std::vector<Object> justTheFirstElemOfObjs;
justTheFirstElemOfObjs.push_back(allObjs.front());
allObjs = justTheFirstElemOfObjs;
allObjs.resize(1);
应该做技巧。
相关文章:
- 为什么它只打印双链接列表的第一个值,而我的程序却崩溃了
- std::find,返回所有找到的值的替代方法,而不仅仅是存在重复的向量的第一个值
- 为什么在 std::map 上移动无法将元素从一个映射移动到另一个映射
- 如何仅读取文本文件中的第一个值
- 在C++中,如何在第一个"system()"结束后执行第二个"system()"?
- 查找不在标准中的第一个值::设置<int>最小-最大值
- C++:忽略第一个 cin.ignore 之后的输入
- 在C++中打印多个矢量的第一个值
- C++去除前x个元素的有效方法,在不改变向量大小的情况下将第x+1个元素推到第一个
- C++第一个cout将不会打印
- 我们可以在第一个else-if条件结束后使用另一个else-if条件吗
- OpenGL:第二个VBO破坏了第一个VBO
- 为什么第一个Dynamic_cast没有投射到基类?
- OpenGL 2D游戏只绘制第二个精灵纹理而不是第一个
- C++ 为什么程序只读取第一个值
- 在我的第一个C++程序中需要一些帮助(简单)
- 将顶部堆栈元素传输到第二个堆栈的第一个
- 获取不等于特定值的向量的第一个N元素
- 如何将std ::映射的第一个N元素复制到另一个地图
- 如何在C中获取char阵列的第一个X元素?提升效果是否有改进的方法