当前位置:网站首页>Std:: vector copy, append, nested access
Std:: vector copy, append, nested access
2022-07-29 10:57:00 【Miaowei】
stl List of articles
List of articles
Preface
std::vector Copy 、 Additional 、 Nested access
One 、 Copy
1. Using the copy assignment operator ( Deep copy ), Note that the left value will be cleared first , Then copy the right value to the left value
vector<int> rightArray{
8,3,5,2,6,4,1};
vector<int> leftArray{
9,1,2,3};
leftArray= rightArray;
Before copying :
After the assignment :
The original :leftArray Medium 9,1,2,3 It was emptied first , Then put the rightArray{ 8,3,5,2,6,4,1 }; Copied to the leftArray in 
2. Make use of copy construction ( Deep copy )
vector<int> rightArray{
8,3,5,2,6,4,1 };
vector<int> leftArray(rightArray);

3. utilize swap() function ( Two exchanges vector)
leftArray and rightArray The original value will be cleared first , Then exchange values with each other
Exchange before 
After exchanging 
4. utilize assign() function ( Empty and copy deeply )
rightArray Will be emptied first. , Then take it. leftArray Copied to the rightArray
Before assignment 
After the assignment :
4. Memory copy ( Deep copy )
memmove front 
memmove after :rightArray Empty the whole thing , Including redundant {4,1 Will also be emptied ,leftArray{ 9,0,7,7,0 }; Will retain 
边栏推荐
- ES6 arrow function this points to
- R language brca MRNA data set analysis
- Use tidymodels to solve the binary logistic model
- How to realize the function of adding watermark
- ECCV 2022 | SSP: 自支持匹配的小样本任务新思想
- WPF 截图控件之绘制方框与椭圆(四) 「仿微信」
- Basic. Blocking
- Site data collection -scrapy usage notes
- 为什么应该在开发环境中使用 Kubernetes
- 深入理解C# 可空类型
猜你喜欢

Alibaba P8 broke out this interview guide for big factories. After reading it, the salary soared by 30K!

Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter

Analysis of QT basic engineering

JVM知识点详细整理(长文警告)

QT工程基本构建

幸运抽奖系统带后台源码

Drawing box and ellipse of WPF screenshot control (IV) "imitating wechat"

DNS协议、ICMP协议、NAT技术

DoD 和 DoR,消减「认知偏差」的两大神器

美团、饿了么被杭州市监约谈要求落实食品安全管理责任 严禁恶意竞争
随机推荐
How to synchronize when the primary and sub warehouses are modified?
【图像检测】基于灰度图像的积累加权边缘检测方法研究附matlab代码
Luogu p1816 loyalty solution
美团、饿了么被杭州市监约谈要求落实食品安全管理责任 严禁恶意竞争
JS two array objects for merging and de duplication
如何在匹配行之前使用 grep 显示文件名和行号
如何使用 grep 跨多行查找模式匹配
R language uses data set veteran for survival analysis
Using R-Pack premsim to predict microsatellite instability based on gene expression
幸运抽奖系统带后台源码
Factoextra: visual PCA of multivariate statistical methods
暑假集训week1
Using Riemann sum to calculate approximate integral in R language
自采集在线电脑壁纸php源码v2.0自适应端
Understand what a binary tree is (types, traversal methods, definitions of binary trees)
从零开始Blazor Server(3)--添加cookie授权
️ 炒 股 实 战丨原 地 起 飞 ️
报表控件FastReport与StimulSoft功能对比
Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter
ES6 arrow function this points to