STL_set——set::find

2023-10-27

Reference:
Returns an iterator addressing the location of an element in a set that has a key equivalent to a specified key.

Function:
iterator find(
   const Key& _Key
) const;
const_iterator find(
   const Key& _Key
) const;

Parameter:
_Key:The argument key to be matched by the sort key of an element from the set being searched.

Return Value:
An iterator or const_iterator that addresses the location of an element equivalent to a specified key or that addresses the location succeeding the last element in the set if no match is found for the key.

Remarks:
The member function returns an iterator that addresses an element in the set whose sort key is equivalent to the argument key under a binary predicate that induces an ordering based on a less-than comparability relation.
If the return value of find is assigned to a const_iterator, the set object cannot be modified. If the return value of find is assigned to an iterator, the set object can be modified.

Example:
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   set <int> s1;
   set <int> :: const_iterator s1_AcIter, s1_RcIter;
   
   s1.insert( 10 );
   s1.insert( 20 );
   s1.insert( 30 );

   s1_RcIter = s1.find( 20 );
   cout << "The element of set s1 with a key of 20 is: "
        << *s1_RcIter << "." << endl;

   s1_RcIter = s1.find( 40 );

   // If no match is found for the key, end( ) is returned
   if ( s1_RcIter == s1.end( ) )
      cout << "The set s1 doesn't have an element "
           << "with a key of 40." << endl;
   else
      cout << "The element of set s1 with a key of 40 is: "
           << *s1_RcIter << "." << endl;

   // The element at a specific location in the set can be found 
   // by using a dereferenced iterator addressing the location
   s1_AcIter = s1.end( );
   s1_AcIter--;
   s1_RcIter = s1.find( *s1_AcIter );
   cout << "The element of s1 with a key matching "
        << "that of the last element is: "
        << *s1_RcIter << "." << endl;
}

Output:
The element of set s1 with a key of 20 is: 20.
The set s1 doesn't have an element with a key of 40.
The element of s1 with a key matching that of the last element is: 30.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

STL_set——set::find 的相关文章

随机推荐

  • ctfshow-Misc入门 图片篇(50-60)

    八神出的misc入门系列 misc57 59做的比较晚了 本来想着等解了misc61一块发wp的 忙着比赛和推免就忘了 今天看到群里有人用g4 的工具一把梭了才想起来这个事 misc61等能把原理讲清楚了再发 图片篇 图片篇 颜色通道 mi
  • 经典运放电路详细分析(模拟电子技术)

    运放电路 何为运放电路 由运算放大器组成的电路 简称为运放电路 这些电路可以说是五花八门 是我们学习模拟电子技术的一个重要内容 更是一个电子工程师必须掌握的电路之一 运放电路有多种类型 是不是我们把它们牢牢记住就行了呢 显然不是啦 作为知识
  • Excel打开csv文件时中文内容显示为乱码或问号的解决办法

    有同事遇到这样一个问题 就是打开csv文件后 里面的中文显示乱码或者问号 网上找了很久 没有找到有效的解决方法 改非Unicode编码 windows显示语言 office显示语言都没有用 随后自己研究了一下 发现只要改一个地方就可以正常显
  • JWT校验

    JWT JSON Web Token 的缩写 由三部分组成 Header 头部 Payload 负载 Signature 签名 随着技术的发展 分布式web应用的普及 通过session管理用户登录状态成本越来越高 因此慢慢发展成为toke
  • 特征选择和特征理解

    特征选择和特征理解 特征选择 排序 对于数据科学家 机器学习从业者来说非常重要 好的特征选择能够提升模型的性能 更能帮助我们理解数据的特点 底层结构 这对进一步改善模型 算法都有着重要作用 特征选择主要有两个功能 减少特征数量 降维 使模型
  • Java List与ArrayList

    目录 List的介绍 什么是List List的使用 ArrayList与顺序表 ArrayList简介 ArrayList的使用 ArrayList的常见操作 ArrayList的扩容机制 ArrayList的模拟实现 List的介绍 什
  • 安卓绕过隐藏api限制

    安全设置 出于测试目的 Google 内置了一种在给定 Android 设备上全局禁用隐藏 API 限制的方法 标题为如何启用对非 SDK 接口的访问的问题中链接中的部分 说如下 您可以通过使用以下 adb 命令更改 API 强制策略来启用
  • 云上城之个服务器维护时间,云上城之歌幻乐之城开服时间表_云上城之歌新区开服预告_第一手游网手游开服表...

    今日开服 15 00 三十八区苍炎之门 已经开服 2021 08 10 10 00 三十八区巨石林野 已经开服 2021 08 09 15 00 三十八区荧光要塞 已经开服 10 00 三十八区雷神圣所 已经开服 2021 08 07 10
  • springboot 读取配置报错java.lang.IllegalArgumentException: Could not resolve placeholder ‘xxx.xxx‘

    springboot 读取配置报错java lang IllegalArgumentException Could not resolve placeholder xxx xxx 代码中写的是 Value xxx xxx 由于配置文件中没有
  • 协同无法关闭的问题之一

    StartCoroutine 方法名 和StartCoroutine 方法名 是不一样的 用StartCoroutine 方法名 无法用StopCoroutine 方法名 关闭协同 但是StartCoroutine 方法名 就可以用Stop
  • spdlog同时输出到控制台和文件中,可设置文件大小及数目,define方式

    因为自己想要个题目那种效果的 又没找到很符合的博客 就整合了下大佬们的博客封了个 具体的内容都放到代码注释里了 我这个目前在windows下只能将log文件创建到exe所处的目录中 暂时仍未解决该问题 欢迎大佬指正 已解决 直接将文件名设置
  • acwing 博弈论 拆分-Nim游戏

    include
  • 安装最新版Calico

    准备calico yaml 进入calico网站 Install Calico networking and network policy for on premises deployments 找到 Install Calico gt K
  • Android 对data/data/(your packagename)目录下的数据读写、删除操作

    一 数据存储 App自身的数据存储在 data data packagename 目录下 大致结构如下图 Activity提供了getCacheDir 和getFilesDir 方法 getCacheDir getAbsolutePath
  • qt std::cout 中文乱码

    char out 输入操作 r n std cout lt lt out QString qOut 输入操作 r n std cout lt lt qOut toStdString std cout lt lt qOut toStdWStr
  • python3---情感分析(基于词典中文)

    写在前面 现有的情感分析比较常用的有两种 分别是基于词典的和机器学习 前者也属于非监督学习 后者自然一般属于监督学习 刚开始学情感分析 下面先从 基于词典的情感分析 开始进行 词典 我东搜西找找到了一些感觉是常用的字典 主要有 台湾大学NT
  • 2.NanoPi M1(全志H3)的GPIO控制总结(内核驱动)

    开发环境 VM Ubuntu 编译环境 linux3 4 交叉编译工具 arm linux gcc 4 4 3 GPIO内核驱动程序链接 https download csdn net download ddffyhg 11022291 用
  • ABAP DOI 下载SMW0的EXCEL和WORD模板

    用 FUNCTION SAP OI LOAD MIME DATA 下载SMW0的模板 用METHOD LR PROXY gt OPEN DOCUMENT FROM TABLE 打开模板 没找到和ole一样先下载 在打开的方法 SMWO上载模
  • 用正则表达式爬豆瓣电影数据

    学了正则表达式后 简单的用它来爬取豆瓣网的数据 import re from urllib request import urlopen def getPage url 获取网页的字符串 response urlopen url retur
  • STL_set——set::find

    Reference Returns an iterator addressing the location of an element in a set that has a key equivalent to a specified ke