关联容器使用copy算法,把元素从一个关联容器拷贝到另一个容器
发布日期:2021-05-07 00:57:10 浏览次数:22 分类:精选文章

本文共 443 字,大约阅读时间需要 1 分钟。

#include 
#include
#include
#include
#include
using namespace std;int main(){map
m1 = { {"str1",1},{"str2",2},{"str3",3},{"str4",4},{"str5",5}};map
m2;copy(m1.begin(),m1.end(),inserter(m2,m2.begin()));for(const auto & i : m2) { cout << i.first << endl; cout << i.second << endl; } return 0;}

运行结果: 

str11str22str33str44str55

注意:在实际编程中,我们使用算法的时候,是把一个关联容器当成一个源序列,或者一个目的位置。

上一篇:基于Fmask 4.0对Landsat和Sentinel-2进行云掩膜
下一篇:关联容器迭代器的一个例子

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年04月11日 21时52分28秒