结合两个向量 [英] combining two vectors

查看:81
本文介绍了结合两个向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单有效的方法来组合两个< vector> s,而不是

,而不是从一个元素中取出每个元素并将其添加到另一个元素中?


我还没有找到任何关于这个

类型操作的指导或示例。


谢谢,Alan

Is there an easy and efficient way to combine two <vector>s, rather
than taking each element from one and adding it to the other?

I haven`t been able to find any guidance on or examples of this
sort of operation.

Thanks, Alan

推荐答案

Alan写道:
Alan wrote:

是否有一种简单有效的方法来组合两个< ; vector> s,而不是
比从一个元素中取出每个元素并将其添加到另一个元素?


我还没有找到任何指导或者这个

类操作的例子。
Is there an easy and efficient way to combine two <vector>s, rather
than taking each element from one and adding it to the other?

I haven`t been able to find any guidance on or examples of this
sort of operation.



vector1.insert(vector1.end(),vector2.begin(),vector2。结束());


-

伊恩柯林斯。

vector1.insert( vector1.end(), vector2.begin(), vector2.end() );

--
Ian Collins.


伊恩,谢谢! Alan

Ian, Thanks! Alan


Ian Collins schrieb:
Ian Collins schrieb:

Alan写道:
Alan wrote:

>是否有一种简单有效的方法来组合两个< vector>,而不是将每个元素从一个元素中添加到另一个元素中?

我还没有找到任何有关此类操作的指导或示例。
> Is there an easy and efficient way to combine two <vector>s, rather
than taking each element from one and adding it to the other?

I haven`t been able to find any guidance on or examples of this
sort of operation.



vector1.insert(vector1.end(),vector2.begin(),vector2.end ());


vector1.insert( vector1.end(), vector2.begin(), vector2.end() );



这很容易 - 是的。

但这真的很有效吗?

在vector1上反复调用push_bask()不是没有效率吗?


/ S

-

Stefan Naewe

stefan_DOT_naewe_AT_atlas_DOT_de

It''s easy - yes.
But is it really efficient ?
Isn''t it as unefficient as repeatedly calling push_bask() on vector1 ?

/S
--
Stefan Naewe
stefan_DOT_naewe_AT_atlas_DOT_de


这篇关于结合两个向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆