C++两个区间的比较?——STL之equal()算法和mismatch()算法

C++ - equal(比较两个vector元素) 在使用std::equal函数时,您需要提供两个范围的迭代器,以及一个可选的谓词函数(predicate)。函数会比较第一个范围内的元素和第二个范围内的元素是否相等。否则返回false。我们使用std::equal函数来比较vec1和vec2以及vec1和vec3。结果表明vec1和vec2相等,而vec1和vec3不相等。在这个例子中,我们有三个向量:vec1,vec2和vec3。vec1和vec2包含相同的元素,而vec3在最后一个元素上有所不同。C++标准库的std::equal函数。 阅读详情

equal()算法         检验相等性

bool 
equal(InputIterator1 beg,InputIterator1 end,
        InputIterator2 cmpBeg)

bool 
equal(InputIterator1 beg,InputIterator1 end,
        InputIterator2 cmpBeg,BinaryPredicate op)
  • 第一形式判断区间[beg,end)内的元素是否都和“以cmpBeg 开头的区间”内的元素相等
  • 第二形式判断区间[beg,end)内的元素和“以cmpBeg开头的区间”内的对应元素是否都能够使以下二元判断式为true:        op(elem,cmpElem)
  • op在函数调用过程中不应该改变自身状态,并且op不应改动传入的参数
  • 调用者必须确保“以cmpBeg开头的区间”内含足够元素
  • 当序列不相等时,如果想要了解其间的不同,应使用mismatch()算法

下面用一个例子展示equal()算法两种形式的用法。第一次用来判断两个区间的元素是否相等,第二次调用使用一个辅助判断式,检查两个序列中的元素是否具备一一对应的奇偶关系:

#include"algostuff.h"
using namespace std;
bool bothEvenOrodd(int elem1, int elem2)
{
	return elem1 % 2 == elem2 % 2;
}

int main()
{
	vector<int> col1;
	list<int> col2;

	INSERT_ELEMENTS(col1,1,7);
	INSERT_ELEMENTS(col2, 3, 9);
	
	PRINT_ELEMENTS(col1, "col1: ");		//col1: 1 2 3 4 5 6 7
	PRINT_ELEMENTS(col2, "col2: ");		//col2: 3 4 5 6 7 8 9

	//check whether both collection are equal
	if (equal(col1.begin(), col1.end(), col2.begin()))
	{
		cout << "col1==col2" << endl;
	}
	else
	{
		cout << "col1!=col2" << endl;
	}

	//check for corresponding even and odd elements
	if (equal(col1.begin(), col1.end(), col2.begin(), bothEvenOrodd))
	{
		cout << "even and odd elements correspond" << endl;
	}
	else
	{
		cout << "even and odd elements do not correspond" << endl;
	}
}

mismatch()算法        搜寻第一处不同点

pair<InputIterator1,InputIterator2>
mismatch(InputIterator1 beg,InputIterator1 end,
        InputIterator2 cmpBeg)


pair<InputIterator1,InputIterator2>
mismatch(InputIterator1 beg,InputIterator1 end,
        InputIterator2 cmpBeg,
        BinaryPredicate op)
  • 第一形式返回区间[beg,end)和“以cmpBeg开头的区间”之中第一组两两相异的对应元素
  • 第二形式返回区间[beg,end)和“以cmpBeg开头的区间”之中第一组“使以下二元判断式为false”的对应元素:        op(elem,cmpElem)
  • 如果没有找到相异点,就返回一个pair,以end和第二序列的对应元素组成。这并不意味着两个序列相等,因为第二个序列可能包含较多的元素
  • op在函数调用过程中不应该改变自身状态,并且op不应改动传入的参数
  • 调用者必须确保“以cmpBeg开头的区间”内含足够元素

下面展示这个程序的用法: 

第一次调用mismatch()用以搜寻第一对互异的对应元素,如果找到了就把它们的值写到标准输出装置。第二次调用用来搜寻符合以下条件的第一对元素,“第一序列的元素比第二序列的对应元素大”,找到后返回这两个元素 

#include"algostuff.h"
using namespace std;
int main()
{
	vector<int> col1;
	list<int> col2;

	INSERT_ELEMENTS(col1, 1, 6);
	for (int i = 1; i <= 16; i *= 2)
	{
		col2.push_back(i);
	}
	col2.push_back(3);
	PRINT_ELEMENTS(col1, "col1: ");		//col1: 1 2 3 4 5 6
	PRINT_ELEMENTS(col2, "col2: ");		//col2: 1 2 4 8 16 3

	//find first mismatch
	pair<vector<int>::iterator, list<int>::iterator> values;
	values = mismatch(col1.begin(), col1.end(), col2.begin());
	if (values.first == col1.end())
	{
		cout << "no mismatch" << endl;
	}
	else
	{
		cout << "first mismatch: "
			<< *(values.first) << " and " << *(values.second) << endl;
	}

	//find first position where the element of col1 is not less than the corresponding element of col2
	values = mismatch(col1.begin(), col1.end(),		//first range
		col2.begin(),								//second range
		less_equal<int>());							//criterion
	if (values.first == col1.end())
	{
		cout << "always less-or-equal" << endl;
	}
	else
	{
		cout << "not less-or-equal: "
			<< *(values.first) << " and "
			<< *(values.second) << endl;
	}
}

 程序运行结果如下

【C++】需要在switch语句中实现范围判断 成绩层次 利用switch语句判断小明的成绩在班里的层次(满分100):>=90分,优秀;>=80分,良;>=60分,及格;<60分,不及格。 – 输入描述: 一行,一个整数表示小明的成绩 输出描述: 一行,一个字符串,优秀为"perfect",良为"great",及格为"good",不及格为"miss" // 嗯我非常蠢得实现了,看了下答案,还是答案写得优美 int main() { int s, flag; cin >> s; if (s&. 阅读详情

相关推荐

C++ STL非更易型算法 查找第一处不同mismatch使用方法

检查[_First,_Last)区间和以_First2起始的区间内第一组两两相异的对应元素 检查[_First,_Last)区间和以_First2起始的区间内第一组造成_Pred(elem,_First2Elem)为false的对应婴元素 如果没有找到就返回以end和第二序列对应的元素组成的pair<> 如果想知道两个序列是否相等,使用equal()算法 复杂度:线性,最多比较nu...

qq_44800780的博客 316

C++ equal()函数详解

C++ equal()函数详解

Solititude的博客 1591

告别‘线束丛林’:手把手拆解车身域控制器(BCM/PEPS/网关)的硬件选型与PCB布局要点

本文深入解析车身域控制器的硬件选型与PCB布局要点,涵盖主控MCU选择、通信接口设计、电源架构优化及EMC设计等关键环节。通过实战案例分享,帮助工程师解决高密度集成带来的电源完整性、热管理和信号隔离挑战,实现更稳定高效的汽车电子系统设计。

weixin_42567279的博客 395

C++ equal()算法解析

equal()算法比较简单,它的作用是比较两个容器是否相等然后返回布尔值,它有两种重载的实现方式,先看下算法的定义: // TEMPLATE FUNCTION equal WITH PRED template<class _InIt1, class _InIt2, class _Pr> inline bool _Equal(_InIt1 _First1, _InIt1 _Las...

先闻其声的博客 1万+

最新版Node.js下载安装及环境配置教程(非常详细)

选择对应你系统的Node.js版本。

DN金猿的博客 12万+

【win11+vs 2017+OpenCV4.5.5+Qt5.12配置】详细安装过程+小问题解决

由于Qt5无法与最新的vs2022兼容,扩展工具中一直显示不可用,所以将vs降级成vs2017。在安装Qt的过程中,会选择安装Qt套件,其中就的MCVS 2017,说明vs2017是与qt兼容的。当然也可以用qt creator这一原生IDE。OpenCV版本目前是最新的4.8.0,使用过程中没有什么问题,但是还是安装低版本大概率避免一些玄学问题。

qq_45306739的博客 3350

C++11标准模板(STL)- 算法 - 比较操作 (std::equal)

1,3) 如果范围 [first1, last1) 和范围 [first2, first2 + (last1 - first1)) 相等,返回 true ,否则返回 false

qq_40788199的博客 3456

ClaudeCode入门01-环境安装(小白入门:手把手教你配置,超简单的一种接入方式)

文手把手教你从零搭建 Claude Code 开发环境。针对国内网络现状,我们采用 OpenRouter + Claude Code Router 的方案,支持支付宝/微信充值,无需科学上网即可完成配置。内容涵盖 Node.js 安装(macOS/Windows/Linux)、OpenRouter 注册与充值、Claude Code 和 Router 安装配置,以及一键启动脚本的编写。跟着截图一步步操作,10分钟搞定全部环境!

yueyeguzhuo的专栏 280

cb36a_c++_STL_算法_区间的比较equal_mismatch_lexicographical_compare

*cb36a_c++_STL_算法_区间的比较equal_mismatch_lexicographical_compare 区间:容器中的全部数据或者部分数据,都叫做区间 equal(b,e,b2),比较两个容器数据是不是相等 ,b(容器1,迭代器begin()),e(容器1,迭代器end(),b2(容器2,迭代器2指向的位置,begin2 if(equal(ivec.begin(),ivec...

Txwtech 491

2024阅读AOSP源码的正确打开姿势

在Android系统开发中,阅读AOSP(Android Open Source Project)源码是非常重要的环节。然而,如何构建一个优雅的阅读环境却是一个不容忽视的问题。本文将介绍不同工具和方法下阅读AOSP源码的正确姿势,并对比其优缺点。

虎哥LoveDroid 2707

通用抓取————6D位姿估计

这意味着算法在没有物体的先验知识(如 CAD 模型)的情况下,依然能够通过神经网络捕捉物体的外观、形状和几何特征,生成相关的 6D 位姿估计。通过输入物体类别的描述,算法能够推断出该类别物体的位姿和尺度,无需特定物体的 CAD 模型。在这个坐标空间中,物体的位姿和尺度都是已知的,基于这个标准化表示,算法可以对输入图像中的物体进行 6D 位姿和尺寸的估计。○优势: ICP 是一种非常有效的位姿优化算法,特别适合精细调整物体的位姿,确保最终估计的位姿与真实物体的点云或模型高度一致。

具身机器人和通用AI 2380

STL mismatch比较算法

equal() 算法可以告诉我们两个序列是否匹配。mismatch() 算法也可以告诉我们两个序列是否匹配,而且如果不匹配,它还能告诉我们不匹配的位置。 mismatch() 的 4 个版本和 equal() 一样有相同的参数——第二个序列有或没有结束迭代器,有或没有定义比较的额外的函数对象参数。mismatch() 返回的 pair 对象包含两个迭代器。它的 first 成员是一个来自前两个参...

JIWilliams 891

Ambari 安装部署教程(手把手教学)【超级详细】

本文为读者提供了一套超详细的 Apache Ambari 安装部署教程,采用手把手教学方式,适合初学者及大数据运维人员。内容涵盖前期准备、环境配置、Ambari Server 与 Agent 安装、集群初始化配置、常见问题排查等全流程操作,确保用户能够顺利搭建稳定的 Hadoop 大数据平台管理系统。

Five的博客 1万+

STL算法-05区间的比较

区间的比较 equal(b, e, b2):第一个容器迭代器[b, e)和第二个容器b2起始的迭代器指向的数据进行比较是否相等。 equal(b, e, b2, p): mismatch(b, e, b2):查找两个容器中第一个不相等的数据。 mismatch(b, e, b2, p) lexicographical_compare(b, e, b2, e2):比较第一个迭代器区间[b, e)是否比第二个[b2, e2)小 lexicographical_compare(b, e, b2, e2, p)

weixin_45906246的博客 331

万字长文带你由浅入深夯实ARM汇编基础——汇编指令及寻址方式最全梳理(附示例)!

见到汇编就害怕?读完这篇,扫除汇编拦路虎!!(示例丰富,可做手册,随手查阅!)

车载系统攻城狮 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C++ STL 算法:区间的比较

1、equal(b,e,b2) if(equal(ivec.begin(),ivec.end(),ilist.begin())) cout << "这两个区间相等" << endl; else cout 2、equal(b,e,b2,p) bool bothEvenOrOdd(int elem1, int elem2) { return elem1 % 2 == elem2 % 2;

梦幻DUO的游戏开发之路 627

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

比较两个ranges(equal,mismatch,lexicographical_compare)

euqal   比较两个序列是否相等,相等返回true,不相等返回false //版本一:调用重载operator==比较元素 template <class InputIterator1,class InputIterator2> bool equal(InputIterator1 first1,InputIterator1 last1,InputIterator2 f...

weixin_30824479的博客 131

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

C++ mismatch(STL mismatch)算法详解

可以用和比较字符串类似的方式来比较序列。如果两个序列的长度相同,并且对应元素都相等,equal() 算法会返回 true。有 4 个版本的 equal() 算法,其中两个用 == 运算符来比较元素,另外两个用我们提供的作为参数的函数对象来比较元素,所有指定序列的迭代器都必须至少是输入迭代器。用 == 运算符来比较两个序列的第一个版本期望 3 个输入迭代器参数,前两个参数是第一个序列的开始和结束迭代器,第三个参数是第二个序列的开始迭代器。如果第二个序列中包含的元素少于第一个序列,结果是未定义的。

断点 867

STL_算法_区间的比较(equal、mismatch、 lexicographical_compare)

C++ Primer 学习中。。。   简单记录下我的学习过程 (代码为主) //所有容器适用 equal(b,e,b2)       //用来比较第一个容器[b,e)和第二个容器b2开头,是否相等 equal(b,e,b2,p) mismatch(b,e,b2)    //用来查找两个容器中第一个不相等的数据,返回迭代器 mismatch(b

寻找&星空の孩子 1479

C++ STL算法系列5---equal() , mismatch()

equal和mismatch算法的功能是比较容器中的两个区间内的元素。这两个算法各有3个参数first1,last1和first2.如果对 于区间[first1,last1)内所有的first1+i,first1+i和first2所在位置处的元素都相等,则equal算法返回真,否则返 回假。mismatch算法的返回值是由两个迭代器first1+i和first2+i组成的一个pair,表示第1对不

dearwind153的专栏 1693

STL_mismatch ,equal 的用法

//mismatch 和 equal 都是比较两个区间内的元素,各有三个参数first1,last1,first2,  //对于【first1,last1)内所有位置first1+i,first1+i和first2+i所在位置处的元素相等 ,equal 返回true。 //pair 返回值是由first1 + i 和 first2 + i组成的一个pair,表示第一对不等元素的位置,如果没有找

以现在的努力程度之低,谈狗屁的未来,屎的梦想!!! 2351

<algorithm>文件中的mismatch、equal、is_permutation算法学习

学习文件中的mismatch、equal、is_permutation的功能和用法学之前需要搞懂前向迭代器含义:可反复读的单向链表指针 , 可以从头到尾遍历,也能复制迭代器,多个迭代器各自独立遍历同一序列,同一个元素可多次读取迭代器功能强弱:输入迭代器 -> 前向迭代器 -> 双向迭代器 -> 随机访问迭代器 -> 连续迭代器输入迭代器: 一次性只读数据,读一个少一个,不能重复读取,也不能复制数据(典型std::istream_iterator , ostream_iterator)

qq_36606147的博客 717

C++ STL 通用算法——查找和搜索算法篇

在C++中,STL 以函数模板提供了很多的通用的算法。 本篇博客只是粗略的给大家归纳了下一些常用查找和搜索算法的函数。 本博主在写这篇博客,主要是参考了《C++泛型:STL原理和应用》清华大学出版社,这一本书。有兴趣的,大家可以自己翻看这本书。 接下来就进入正题 在进入正题之前,你需要了解C++的迭代器和容器。至少能够知道这两个是什么。 查找和搜索算法 下面函数内的参数,使用的 it_first, it_second 等,是指迭代器的开始,和迭代器的结束,这里进行统一说明下。 使用通用算法前,需要在程

qq_44656336的博客 798

STL算法(15)——区间的比较

STL算法——区间的比较: equal(b,e,b2) // 用来比较两个容器中的数据是否相等 equal(b,e,b2,p) mismatch(b,e,b2)    // 用来查找两个容器中第一个不相等的数据 mismatch(b,e,b2,p) lexicographical_compare(b,e,b2,e2) //用来比较第一个区间是否比第二个区间小 lexic

taotaoahui 976
上一篇: STL之search()算法
下一篇: C++实现二分查找(力扣题目704)
yangSHU21
博客等级 码龄4年 303粉丝 96原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值