使用插入迭代器复制算法...

编程入门 行业动态 更新时间:2024-10-10 00:22:07
本文介绍了使用插入迭代器复制算法...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我养成了经常使用副本和插入 迭代器的习惯。在某些情况下,我会以这种方式处理大量数据。 有人能给我一个普遍的感觉,那就是我有多大的表现能够获得使用这种技术而不是使用''copy''直接复制到元素到位的 容器中? 谢谢, d

I have gotten into the habit of often using copy along with an insert iterator. There are scenarios where I process quite a lot of data this way. Can someone give me a general feel as to how much of a performance hit I''m taking using this technique versus using ''copy'' to copy directly into a container with elements in place? Thanks, d

推荐答案

" deancoo" < S2 ******* @ yahoo.ca>在消息中写道 news:k7KWd.11823 "deancoo" <s2*******@yahoo.ca> wrote in message news:k7KWd.11823

KI2.9259@clgrps12 ... KI2.9259@clgrps12... 我养成了习惯经常使用副本和插入迭代器。在某些情况下,我会以这种方式处理大量数据。有人能给我一个普遍的感觉吗?我正在使用这种技术,而不是使用''copy''直接复制到具有元素的容器中? br /> 谢谢, d I have gotten into the habit of often using copy along with an insertiterator. There are scenarios where I process quite a lot of data thisway. Can someone give me a general feel as to how much of a performance hitI''m taking using this technique versus using ''copy'' to copy directly into acontainer with elements in place? Thanks, d

一如既往,如果你有严格的性能要求,你应该这样做 时间研究。但是,你要求一般的感觉。一般来说,它不是坏bb b。比如使用std :: vector你可以做 std :: vector< double> v(10000); std :: copy(ptr,ptr + 10000,& v [0]); 将保存10000次push_back操作,但现在你必须在覆盖它们之前将初始化10000倍到0.0。你正在使用的 替代品可能是 std :: vector< double> v; v.reserve(10000); //不要忘了这个 std :: copy(ptr,ptr + 10000,std :: back_inserter(v)); 每一步都有一点记账 - 可能会增加一个最后指针 - 但是使用复制构造函数进行初始化。如果你没有在std :: copy之前保留足够的内存,那么对象将不得不多次重新分配 内存。 - Cy http ://home.rochester.rr/cyhome/

" Cy Edmunds" < CE ****** @ spamless.rochester.rr>在消息中写道 news:wn ******************* @ twister.nyroc.rr ... "Cy Edmunds" <ce******@spamless.rochester.rr> wrote in message news:wn*******************@twister.nyroc.rr... deancoo < S2 ******* @ yahoo.ca>在消息中写道新闻:k7KWd.11823 "deancoo" <s2*******@yahoo.ca> wrote in message news:k7KWd.11823

更多推荐

使用插入迭代器复制算法...

本文发布于:2023-11-30 12:48:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650028.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:算法   迭代

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!