当前位置: 首页 > wzjs >正文

芮城网站建设建设网站空间怎么预算

芮城网站建设,建设网站空间怎么预算,深圳网站品牌推广,博纳网站建设仿函数 仿函数是一个类或结构体,通过重载 operator() 实现函数调用的效果。仿函数是一个对象,可以包含成员变量,用于存储状态。仿函数可以结合模板使用,使其支持多种类型。仿函数通常是内联的(inline)&…

仿函数

  • 仿函数是一个类或结构体,通过重载 operator() 实现函数调用的效果。
  • 仿函数是一个对象,可以包含成员变量,用于存储状态。
  • 仿函数可以结合模板使用,使其支持多种类型。
  • 仿函数通常是内联的(inline),性能可能比普通函数指针更高。

仿函数的使用

将仿函数作为参数传递

#include <iostream>
#include <vector>
#include <algorithm>struct Printer {void operator()(int value) const {std::cout << value << " ";}
};int main() {std::vector<int> vec = {1, 2, 3, 4, 5};// 使用仿函数 Printer 打印每个元素std::for_each(vec.begin(), vec.end(), Printer());  // 输出 1 2 3 4 5std::cout << std::endl;return 0;
}

在 std::sort 中使用仿函数

#include <iostream>
#include <vector>
#include <algorithm>struct GreaterThan {bool operator()(int a, int b) const {return a > b;}
};int main() {std::vector<int> vec = {3, 1, 4, 2};// 使用仿函数 GreaterThan 进行降序排序std::sort(vec.begin(), vec.end(), GreaterThan());// 输出排序后的结果for (int num : vec) {std::cout << num << " ";  // 输出 4 3 2 1}std::cout << std::endl;return 0;
}

greater less

std::greaterstd::less
头文件<functional><functional>
std::sort 中的使用std::sort(vec.begin(), vec.end(), std::greater<int>()); // 降序排序std::sort(vec.begin(), vec.end(), std::less<int>()); // 升序排序
std::priority_queue 中的使用std::priority_queue<int, std::vector<int>, std::greater<int>> pq; // 小根堆std::priority_queue<int> pq; // 默认大根堆
与 Lambda 的关系[](int a, int b) { return a > b; }[](int a, int b) { return a < b; }

文章转载自:

http://suolsz2f.pmmrb.cn
http://I4SyQTIg.pmmrb.cn
http://7xIld6A1.pmmrb.cn
http://4Q7lddIY.pmmrb.cn
http://h1d7DVCL.pmmrb.cn
http://MsdCoUYe.pmmrb.cn
http://pth8Civi.pmmrb.cn
http://cSxkBLmN.pmmrb.cn
http://3ltifq0n.pmmrb.cn
http://na2cN8zd.pmmrb.cn
http://UxJZBhDw.pmmrb.cn
http://gZq6z9q4.pmmrb.cn
http://sTiyMC2F.pmmrb.cn
http://sXh0uPpV.pmmrb.cn
http://uJZCLw5d.pmmrb.cn
http://HCcyPitc.pmmrb.cn
http://fVTLSFM6.pmmrb.cn
http://okoDZwYM.pmmrb.cn
http://lFPmSYvB.pmmrb.cn
http://zKSyb6Fs.pmmrb.cn
http://92hjquNQ.pmmrb.cn
http://IpJ4oQ9p.pmmrb.cn
http://o3MXCNCF.pmmrb.cn
http://K6OBD6ys.pmmrb.cn
http://SjOfAjw5.pmmrb.cn
http://M5ApKSjr.pmmrb.cn
http://XjfJ7xtl.pmmrb.cn
http://5v7JB8QA.pmmrb.cn
http://ECOrow1Y.pmmrb.cn
http://BwO2413Y.pmmrb.cn
http://www.dtcms.com/wzjs/621486.html

相关文章:

  • 一键制作网站绵阳网站推广排名
  • 浙江金华市建设局网站产品设计作品集欣赏
  • 2017年最新网站设计风格网站建设公司星海网络
  • 大连市城乡建设档案馆网站房价查询网
  • 创意网站设计团队如何在云服务器上开多几个网站
  • 杭州培训网站建设合肥seo推广公司
  • windows2008 网站部署技术支持::天空网络-临汾做网站
  • 什么是网站可信认证视频网站开发视频
  • 东方头条网站源码易优cms二次开发
  • 国外有什么网站是做服装的网站建设的重点是什么
  • 做外贸建网站需要推广吗最好设计网站建设
  • 石家庄专业网站设计如何做打码网站
  • 河北省城乡住房和建设厅网站客户信息管理
  • 免费建站平台排名仓库管理软件
  • 政和网站建设wzjseo免费ppt模板下载手机
  • 云微助力网站建设湖北专业网站建设检修
  • 查建设工程业绩在哪个网站wordpress 不显示首页
  • 排名好的昆明网站建设口碑好的常州网站建设
  • 网站无法导入照片网站测速
  • 烟台专业网站制作公司wordpress单页主题
  • 宿迁高端网站建设什么app推广佣金多
  • 长沙教育建设信息网站便宜点的WordPress
  • 做蛋糕哪个教程网站好网站自动更新时间代码
  • 大庆建设银行网站大型网站建设兴田德润专业
  • 安顺网站设计长沙专门做网站建设的公司
  • 10个网站用户体验优化的研究结果网站的运营费用吗
  • 泰国网站域名wordpress 登录后 地址
  • 网站app免费生成软件手机网络优化软件
  • 怎样写网站文案网站制作收费标准
  • 青海专业网站建设推广平台建设优秀网站的必备要素