当前位置:网站首页>遍历vector容器中的对象的方式
遍历vector容器中的对象的方式
2022-06-29 08:49:00 【一大块肉松】
1.使用 auto进行遍历:for(auto i : v)
完整代码示例如下图
2、使用迭代器进行遍历iterator,使用该方法首先你需要先创建属于这个容器的迭代器,例如:vector::iterator
然后再使用循环对容器进行遍历。代码示例如下图所示:
上图代码中的vector::iterator it = v.begin() ,可以直接用auto it=v.begin() 来代替:原因是auto可以根据后面的值,来推测类型是什么。
边栏推荐
- Closed training (25) basic web security
- Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks
- The former security director of Uber faced fraud allegations and had concealed data leakage incidents
- Universal target detection based on region attention
- Pytorch summary learning series - broadcast mechanism
- Gd32f4xx Ethernet chip (ENC28J60) driver migration
- 长安链GO语言智能合约编写与编译
- 长安链GO语言智能合约环境搭建及使用
- 深入RC、RS、DaemonSet、StatefulSet(七)
- LSM6DSL之SPI驱动
猜你喜欢

UE4 material UV texture does not stretch with model scale

3DMax 卡死、白屏、渲染死机问题总结

Share code snippets of wechat applet

Gd32f4xx Ethernet chip (ENC28J60) driver migration

Simplicity Studio无法识别新买的JLink v9解决方法

GD32F4xx 以太網芯片(enc28j60)驅動移植

UE4 remove the mask transparent white edge in the material

Wechat applet sharing page, sharing to the circle of friends

Visual assist plug-in settings for UE4 vs

Lc236. nearest common ancestor of binary tree
随机推荐
Self cultivation (XXI) servlet life cycle, service method source code analysis, thread safety issues
Hb5470 combustion test of non-metallic materials in civil aircraft cabin
pytorch总结学习系列-数据操作
UE4 材质UV纹理不随模型缩放拉伸
基于stm32标准库独立按键的多按键状态机的实现
Yotact real-time instance segmentation
Reading notes on how to connect the network - Web server request and response (IV)
programing language
基于keil5自动配置stm32f103标准库的官网freertos移植
证券账号开户安全吗?是靠谱的吗?
Modify EXIF information
云管理平台:9大开源云管理平台(CMP)
Redo after JS rotation view (longer full version, can be run)
pytorch总结学习系列-操作
Automatic 3D Detection and Segmentation of Head and Neck Cancer from MRI Data.
Data warehouse: layered architecture of Finance / banking
The former security director of Uber faced fraud allegations and had concealed data leakage incidents
商业智能BI的未来,如何看待AI+BI这种模式?
Matlab tips (21) matrix analysis -- partial least squares regression
pytorch总结学习系列-广播机制