(c++ std) 查找 vector 中的元素
2024-10-09 01:43:08
You can use std::find
from <algorithm>
:
std::find(vector.begin(), vector.end(), item) != vector.end()
This returns a bool (true
if present, false
otherwise). With your example:
#include <algorithm> if ( std::find(vector.begin(), vector.end(), item) != vector.end() )
do_this();
else
do_that();
最新文章
- JAVA继承时构造函数的问题
- 【转】jQuery获取Select option 选择的Text和Value
- iOS开发之多线程技术——NSOperation篇
- 分布式拒绝服务攻击 DDoS
- JDK的安装与配置
- android之显示数据库信息
- javaee添加验证码
- Jsoncpp 数组的使用
- Entity Framework CodeFirst------数据迁移(二)
- json数组传递到后台controller
- C++第二天学习
- 面向切面编程(Aop)
- Caused by: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException):
- JDK、JRE、JVM详解
- golang包管理工具glide安装
- Linux基础命令-Nginx-正则表达式( grep sed awk )-Shell Script--etc
- P2789 直线交点数
- Java基础知识(JAVA基本数据类型包装类)
- ubuntu部署nginx
- threading.Condition()
热门文章
- AngularJS插件使用---angular-cookies.js
- CentOS 6.5 nginx+tomcat+ssl配置
- I - 动物狂想曲 HDU - 6252(差分约束)
- 直播回顾 | IOT、AI、云计算等融合技术推进制造业产业转型(二)
- EEPROM存储芯片24C02
- 《Three.js 入门指南》3.1.1 - 基本几何形状 -多面体
- PTA数据结构与算法题目集(中文) 7-36 社交网络图中结点的“重要性”计算 (30 分)
- Nordic nRF52820超低功耗蓝牙5.2 SoC芯片-低端无线连接方案首选
- ssh配置文件最佳实践(伪)
- 《深入理解 Java 虚拟机》读书笔记:晚期(运行期)优化