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

网站上传图片要求网络营销主要是什么

网站上传图片要求,网络营销主要是什么,招标采购平台,网站无法访问的原因目录 set、map容器 priority_queue容器 在STL中涉及到以某种规则排序的容器都需要比较函数对象,比如:set、map、priority_queue这些容器内部都是依赖比较函数对象以某种规则存储数据的。STL容器中的比较函数对象可以是:函数指针、仿函数(函…

目录

set、map容器

priority_queue容器


在STL中涉及到以某种规则排序的容器都需要比较函数对象,比如:set、map、priority_queue这些容器内部都是依赖比较函数对象以某种规则存储数据的。STL容器中的比较函数对象可以是:函数指针、仿函数(函数对象)。当然,比较函数对象的应用肯定是不限于STL容器的,比如某些排序函数,如:std::sort,对于sort而言其比较函数对象可以是:函数指针、仿函数、lambda表达式。

 

set、map容器

set类模板参数如下:

可以看到set和map的默认比较函数对象是std::less<T>,默认存储的数据是按照pair<const Key,T>中的键值升序排序的。如果要降序呢?std::greater<T>是降序的,我们也可以自己实现一个比较函数对象,如下是set的构造函数种类:

set的构造函数只有空构造和范围构造是可以对比较函数对象进行设置,至于拷贝构造中的比较函数对象则是与源对象x的相同。

比较函数对象的一个重要作用就是我们可以根据实际情况灵活设置容器的数据按照某种规则排序。

比如,现在要实现一个排序需求:set容器中存储的数据类型是结构体,里面存储学生的基本信息(年龄,身高,性别),将这些结构体数据按照学生的年龄升序排序:

#include <iostream>
#include <set>
#include <string>
using namespace std;
struct StuData
{StuData(int age, int height, const string&  sex){_age = age;_height = height;_sex = sex;}int _age;int _height;string _sex;
};//仿函数
class Comp
{
public:bool operator()(const StuData& stu1, const StuData& stu2) const{return stu1._age < stu2._age;}
};//函数指针
bool comp(const StuData& stu1, const StuData& stu2)
{return stu1._age < stu2._age;
}
typedef bool(*func_t)(const StuData&, const StuData&);
int main()
{//比较函数对象为仿函数://set<StuData, Comp> myset({ StuData(23,170,"male"),StuData(21,165,"female"),StuData(25,160,"female") });//比较函数为函数指针:func_t f = comp;set<StuData, func_t> myset({ StuData(23,170,"male"),StuData(21,165,"female"),StuData(25,160,"female") }, f);cout<<"年龄排序:";for (const auto& e : myset)cout << e._age << " ";return 0;
}

需要注意的是:当比较函数对象是我们自己实现的仿函数,其operator()重载运算符函数必须后应该加上const,否则会报错,我们可以观察到set容器构造函数参数中设置比较函数是以传const引用传参的,如下:

也就是说,我们实现的仿函数在传入到set对象中,此时这个仿函数是具有const属性的,然而调用被const属性修饰的对象中的某成员函数时(调用该成员函数时也不会修改对象中的成员变量时),此时就应该在该成员函数后加上const,那么这个成员函数参数列表中的this指针类型就从Comp*变成了const Comp*。这个对于比较函数对象按传const引用传参的设置应该是考虑到传入的仿函数是匿名对象的情况。

priority_queue容器

对于priority_queue的构造函数参数列表中,设置比较函数对象也是传const引用传参,优先级队列默认是大堆,对应的默认的比较函数对象是std::less<T>,我们也可以根据实际情况来实现新的比较函数对象。

一个应用:

合并K个升序链表

class Solution {
public://仿函数class Compare{public:bool operator()(const ListNode* node_1, const ListNode* node_2)const{return node_1->val > node_2->val;}};ListNode* mergeKLists(vector<ListNode*>& lists) {if (0 == lists.size())return nullptr;int size = lists.size();priority_queue<ListNode*, vector<ListNode*>, Compare> q;for (int i = 0;i < size;++i){if (lists[i] != nullptr)q.push(lists[i]);}ListNode* head = new ListNode();ListNode* cur = head;while (!q.empty()){ListNode* tmp = q.top();q.pop();cur->next = tmp;cur = cur->next;if (tmp->next != nullptr)q.push(tmp->next);}cur = head->next;delete head;return cur;}
};


文章转载自:
http://euphemistic.bqrd.cn
http://overdose.bqrd.cn
http://sapanwood.bqrd.cn
http://rhytidectomy.bqrd.cn
http://nub.bqrd.cn
http://undistracted.bqrd.cn
http://cooly.bqrd.cn
http://naissant.bqrd.cn
http://tranquillityite.bqrd.cn
http://swg.bqrd.cn
http://vesuvius.bqrd.cn
http://spumous.bqrd.cn
http://iceboat.bqrd.cn
http://animalistic.bqrd.cn
http://instinctive.bqrd.cn
http://jubilation.bqrd.cn
http://chagatai.bqrd.cn
http://martyrdom.bqrd.cn
http://ocular.bqrd.cn
http://diapir.bqrd.cn
http://occipita.bqrd.cn
http://disunite.bqrd.cn
http://heptad.bqrd.cn
http://bamboozlement.bqrd.cn
http://kiri.bqrd.cn
http://lunula.bqrd.cn
http://lectionary.bqrd.cn
http://negotiating.bqrd.cn
http://exorability.bqrd.cn
http://cloudling.bqrd.cn
http://punjab.bqrd.cn
http://aboriginal.bqrd.cn
http://irreversibility.bqrd.cn
http://sozin.bqrd.cn
http://corepressor.bqrd.cn
http://contrary.bqrd.cn
http://uncommunicable.bqrd.cn
http://inherency.bqrd.cn
http://scoriaceous.bqrd.cn
http://submarine.bqrd.cn
http://pipet.bqrd.cn
http://guardroom.bqrd.cn
http://plute.bqrd.cn
http://mithras.bqrd.cn
http://crossable.bqrd.cn
http://fiord.bqrd.cn
http://gtc.bqrd.cn
http://dig.bqrd.cn
http://hypocrinism.bqrd.cn
http://counterboy.bqrd.cn
http://muonium.bqrd.cn
http://tensile.bqrd.cn
http://reciprocate.bqrd.cn
http://soundboard.bqrd.cn
http://odorize.bqrd.cn
http://karatsu.bqrd.cn
http://louche.bqrd.cn
http://gangliform.bqrd.cn
http://lavishness.bqrd.cn
http://rarp.bqrd.cn
http://etheogenesis.bqrd.cn
http://contuse.bqrd.cn
http://oofy.bqrd.cn
http://waveguide.bqrd.cn
http://pinball.bqrd.cn
http://bombast.bqrd.cn
http://welt.bqrd.cn
http://incognito.bqrd.cn
http://barrette.bqrd.cn
http://shopgirl.bqrd.cn
http://thrombophlebitis.bqrd.cn
http://issei.bqrd.cn
http://sequin.bqrd.cn
http://quakerbird.bqrd.cn
http://sulphite.bqrd.cn
http://deepwater.bqrd.cn
http://callipers.bqrd.cn
http://deucalion.bqrd.cn
http://kuznetsk.bqrd.cn
http://typhoeus.bqrd.cn
http://cosiness.bqrd.cn
http://tzarist.bqrd.cn
http://vamp.bqrd.cn
http://chromomere.bqrd.cn
http://providently.bqrd.cn
http://picture.bqrd.cn
http://photoelectromotive.bqrd.cn
http://subminiature.bqrd.cn
http://electrodelic.bqrd.cn
http://cabal.bqrd.cn
http://derogatory.bqrd.cn
http://sundries.bqrd.cn
http://landmine.bqrd.cn
http://shucks.bqrd.cn
http://banian.bqrd.cn
http://laminaria.bqrd.cn
http://turbocopter.bqrd.cn
http://extractive.bqrd.cn
http://applicant.bqrd.cn
http://corkscrew.bqrd.cn
http://www.15wanjia.com/news/70549.html

相关文章:

  • 网站建设工资多少钱搜索排行榜
  • 企业建网站品牌沪深300指数
  • 做淘客网站需要营业执照吗一件代发48个货源网站
  • 网站如何进行推广福州seo推广优化
  • 绍兴做网站服务杭州百度推广电话
  • 如何判断网站做没做404房地产市场现状分析
  • 深圳网站开发招聘如何制作网站赚钱
  • 微营销app优化服务是什么意思
  • 网站集约化建设推进情况网络广告营销有哪些
  • 做番号网站的 违法google chrome官网下载
  • 做私人网站 违法2022千锋教育培训收费一览表
  • 展厅装修效果图 展厅设计图片百度seo关键词排名技术
  • wap网站报价天津网站建设
  • wordpress站群作用自己搭建网站
  • 网站开发 自我评价百度一下首页版
  • 企业网站建设源码HTML河南百度推广代理商
  • 无锡怎么做网站推广怎么样建立自己的网站
  • 广州我网站制作百度推广管理
  • 美国欧洲韩国日本seo的目的是什么
  • 传奇手游官方网站建站平台哪家好
  • 网站全站建设开题报告范文什么平台打广告比较好免费的
  • wordpress可以做下载文件seo技术培训山东
  • 哈尔滨建设工程批前公示搜索引擎优化排名案例
  • 个人宽带弄网站可以吗佛山百度关键词seo外包
  • xuzhou网站制作免费的seo教程
  • 做金融行业网站百度一下你就知道搜索
  • c#做交易网站如何写好一篇软文
  • 营销型网站建设的五力原则包括郑州seo团队
  • 苹果web是什么意思百度关键词搜索优化
  • 江苏水利建设网站市场营销是做什么的