如何在结果列表的开头插入生成的列表
How to insert generated list at the beginning of the result list?
我有一个类似list<T> result;
的列表,在for循环中,我在每次通过时都会生成另一个类似的列表
list<T> result;
for(int i=0;i<10;i++){
list<T> temp=generated_list();
// here I want to add at the beginning of the result list values from temp list
}
如何在结果列表的开头插入生成的列表?有没有比循环或通过串联创建新的,然后将结果设置为结果列表更好的方法?
std::list<T>::splice
成员函数是实现功能的最有效方法
list<T> result;
for(int i=0;i<10;i++){
list<T> temp=generated_list();
result.splice(result.begin(), temp);
}
相关文章:
- 使用列表 STL 递归进行插入排序
- 列表 iter 不取消引用 使用列表进行插入排序
- 列表的有效性在插入后开始迭代器
- 如何通过保持第一个插入的位置来对列表中插入的其余元素进行排序?
- 如何从队列插入到 2D 列表
- 将元素插入链接列表
- 无法在我的链接列表中插入项目,head始终为NULL
- 通过动态分配插入列表元素
- 列表插入"Cannot convert argument from Class<T>* to Class<T> &&"
- 双链接列表插入功能C
- 链接列表插入,指针混乱
- 这个无锁数据列表插入是安全的吗
- STL 列表插入要求 3 个参数
- 将字符串列表插入 2D 矢量
- C++列表::插入编译错误
- 为什么我的列表插入函数不生成新节点
- 基于数组的列表-插入函数
- 使用链接列表插入弹出功能
- c++向量和列表插入
- c++列表插入的奇怪行为