草庐IT

find-links

全部标签

c++ - std::search 是否有一个函数类似于 std::count 对 std::find 的函数?

如果标题听起来很奇怪,这里有另一种解释:如果我有一个范围a,我想计算另一个范围b在范围a中出现了多少次,是否有一个std::函数来做呢?如果不是,是否有一种简单的方法(当然我可以使用std::search手动循环-我说的是更优雅的东西)? 最佳答案 我认为您需要构建自己的。以下是我想到的实现方式。templatesize_tsubsequence_count(Iterator1haystack_begin,Iterator1haystack_end,Iterator2needle_begin,Iterator2needle_end)

c++ - 为什么 std::map find() 没有声明为 noexcept?

C++14标准定义std::map的find()成员函数如下:iteratorfind(constkey_type&x);const_iteratorfind(constkey_type&x)const;为什么这些函数没有定义为noexcept?内部可能出现什么问题,这将需要抛出异常或产生未定义的行为(除了找不到元素,在这种情况下函数返回end迭代器并且无论如何都不需要抛出异常)? 最佳答案 find()基于map的Compare()方法,这可能会引发异常(想象一下复杂键可能不正确的情况).因此,我们不能确定find()不会引发异常

c++ - 为什么 set::find 不是模板?

使用来自的模板函数你可以这样做structfoo{intbar,baz;};structbar_less{//comparefoowithfoobooloperator()(constfoo&lh,constfoo&rh)const{returnlh.bar//comparesomeTwithfoobooloperator()(Tlh,constfoo&rh)const{returnlh//comparefoowithsomeTbooloperator()(constfoo&lh,Trh)const{returnlh.barbaz;}在std::set类似find的方法你必须传递一个s

c++ - g++ : can't link with a main executable file

我正在开发一个使用统计攻击来破解wepkey的应用程序。当我用我的makefile编译时(如上)我得到这个错误:ld:can'tlinkwithamainexecutablefile'execStatAttack'forarchitecturex86_64clang:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)make:*[statAttack]Error1我的项目包含那些文件:statAttack.cpp:包含主要功能,使用上面的文件rc4.h+rc4.cpp:具有那些功能#include#include#i

c++ - 我如何构造一个仿函数以用于像 boost 的 brent_find_minima 这样的算法?

我试图理解为什么不能将具有构造函数的仿函数传递给算法,而没有构造函数的仿函数却可以。对于算法boost-brent_minima。当仿函数没有构造函数时,示例代码工作正常:#includestructfuncdouble{doubleoperator()(doubleconst&x){//return(x+3)*(x-1)*(x-1);//(x+3)(x-1)^2}};intbits=std::numeric_limits::digits;std::pairr=brent_find_minima(funcdouble(),-4.,4./3,bits);std::cout.precisi

c++ - m.find(...) == m.end() - 使用的是 iterator 或 const_iterator

std::mapfind/end都提供const_iterator和迭代器,例如iteratorend();const_iteratorend()const出于好奇,如果我有一个std::map,它将在这里被调用/比较,一个迭代器或一个const_iterator?:if(m.find(key)!=m.end()){...}我应该关心吗? 最佳答案 如果m是const,则返回一个const_iterator;否则将返回一个迭代器。如果您所做的只是测试map中是否存在某个元素,那么使用哪个元素并不重要。

c++ - 如何 std::find 使用比较对象?

我对std::find的接口(interface)感到困惑。为什么它不用Compare对象来告诉它如何比较两个对象?如果我可以传递一个Compare对象,我可以使下面的代码工作,我想在其中按值进行比较,而不是直接比较指针值:typedefstd::vectorVec;Vecvec;std::string*s1=newstd::string("foo");std::string*s2=newstd::string("foo");vec.push_back(s1);Vec::const_iteratorfound=std::find(vec.begin(),vec.end(),s2);//

物联网IOT视频设备如何快速对接阿里云生活物联网(Link Visual)并成功上云?

原文永久更新地址:https://www.yundashi168.com/472.html文章来源:猿视野如果有图片看不清楚,加载不出来,请阅读原文。什么是LinkVisual、LinkVisual是生活物联网平台针对视频产品推出的增值服务,提供视频数据上云、存储、转发、AI计算等能力。大白话就是:通过阿里云的LinkVisual视频服务,可以让你的IPC摄像头设备完成上云功能,并快速实现如下功能介绍中的功能。其中可以享受阿里云P2P协议支持,帮助企业节省流量服务器流量带宽。快速上手入门,请参考阿里云官网文档说明:LinkVisual视频开发技术文档功能介绍LinkVisual提供的设备端SD

c++ - 理论上,find_end 是可并行化的吗?

我目前正在研究open-stdproposal为我正在处理的项目带来并行功能,但我遇到了find_end的障碍。现在find_end可以描述为:Analgorithmthatsearchesforthelastsubsequenceofelements[s_first,s_last)intherange[first,last).Thefirstversionusesoperator==tocomparetheelements,thesecondversionusesthegivenbinarypredicatep.它的要求由cppreference列出.现在我并行化find/findi

c++ - std::find 和 std::map.find 都是 O(logN) 吗?

std::find和std::map.find都是O(logN)吗?如果是,std::find如何在对数时间内实现对std::map的搜索?std::find的实现是否专门用于std::map用例? 最佳答案 不,std::find是O(N),与容器无关。它不知道“容器”,没有针对std::map的专门化。std::find仅使用迭代器,它没有关于底层容器的信息。根据cppreference.com,实现等同于:templateInputItfind(InputItfirst,InputItlast,constT&value){fo