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

五个成功品牌推广案例青岛网站制作seo

五个成功品牌推广案例,青岛网站制作seo,苹果手机怎么做微电影网站,网站建设公司有哪些方面文章目录 仿函数优先队列的模拟实现 仿函数 上回我们说到,优先队列的实现需要用到仿函数的特性 让我们再回到这里 这里我们发现他传入的用于比较的东西竟然是一个类模板,而不是我们所见到的函数 我们可以先创建一个类,用于比较大小 struc…

文章目录

    • 仿函数
    • 优先队列的模拟实现

仿函数

上回我们说到,优先队列的实现需要用到仿函数的特性

让我们再回到这里

这里我们发现他传入的用于比较的东西竟然是一个类模板,而不是我们所见到的函数

我们可以先创建一个类,用于比较大小

struct Less
{bool operator()(int x, int y){return x < y;}
};

这里我们创建了一个Less类,并且重载了圆括号,让他比较x<y是否成立

我们可以这样使用

Less ls;
cout << ls(1, 2) << endl;

结果是1

我们单单从cout这一句来看,ls就好像一个函数一样,可以比较1和2的大小,但是实际上是由Less创建的一个对象来比较的

我们把这一句还原

Less ls;
cout << ls(1, 2) << endl;
cout << ls.operator()(1, 2) <<endl;

实际上后面这一句才是原本的样子

如果我们给这个类加上个模板

例如

template<class T>
struct Less
{bool operator()(T x, T y){return x < y;}
};

这样就可以用来比较不止整形的大小了

这样我们就可以在别的类内部通过类模板来传递函数的功能

讲到这我们就明白了,这个仿函数实际上的功能类似于函数指针,是用来传递函数的逻辑的

这样做的好处是我们可以自行定义需要的函数

例如当堆中的数据为自定义类型,通用的less和greater比较就不起作用了,需要自行定义传入了

优先队列的模拟实现

#include <iostream>
using namespace std;
#include <vector>
namespace xu
{template<class T>struct less{bool operator()(const T& left, const T& right){return left < right;}}; // 仿函数的实现template<class T>struct greater{bool operator()(const T& left, const T& right){return left > right;}}; // 仿函数的实现template<class T, class Container = std::vector<T>, class Compare = less<T>>class priority_queue{public:// 创造空的优先级队列priority_queue() : c() {}template<class Iterator>priority_queue(Iterator first, Iterator last): c(first, last){// 将c中的元素调整成堆的结构int count = c.size();int root = ((count - 2) >> 1);for (; root >= 0; root--)AdjustDown(root);}void push(const T& data){c.push_back(data);AdjustUP(c.size() - 1);}void pop(){if (empty())return;swap(c.front(), c.back());c.pop_back();AdjustDown(0);}size_t size()const{return c.size();}bool empty()const{return c.empty();}const T& top()const{return c.front();}private:// 向上调整void AdjustUP(int child){int parent = ((child - 1) >> 1);while (child){if (Compare()(c[parent], c[child])){swap(c[child], c[parent]);child = parent;parent = ((child - 1) >> 1);}else{return;}}}// 向下调整void AdjustDown(int parent){size_t child = parent * 2 + 1;while (child < c.size()){// 找以parent为根的较大的孩子if (child + 1 < c.size() && Compare()(c[child], c[child + 1]))child += 1;// 检测双亲是否满足情况if (Compare()(c[parent], c[child])){swap(c[child], c[parent]);parent = child;child = parent * 2 + 1;}elsereturn;}}private:Container c;};
}

文章转载自:
http://quittance.c7497.cn
http://degree.c7497.cn
http://semisweet.c7497.cn
http://pickaxe.c7497.cn
http://terpsichorean.c7497.cn
http://locoweed.c7497.cn
http://dehumanization.c7497.cn
http://herniary.c7497.cn
http://euclase.c7497.cn
http://duumvirate.c7497.cn
http://punk.c7497.cn
http://lipide.c7497.cn
http://periphrase.c7497.cn
http://choux.c7497.cn
http://northabout.c7497.cn
http://acetylene.c7497.cn
http://centra.c7497.cn
http://ergotism.c7497.cn
http://confine.c7497.cn
http://cardiogenic.c7497.cn
http://duettist.c7497.cn
http://danaides.c7497.cn
http://deorbit.c7497.cn
http://weeksite.c7497.cn
http://clootie.c7497.cn
http://spreathed.c7497.cn
http://dichogamy.c7497.cn
http://bramley.c7497.cn
http://coom.c7497.cn
http://suspensor.c7497.cn
http://glycosuric.c7497.cn
http://isaias.c7497.cn
http://tomfoolery.c7497.cn
http://expiree.c7497.cn
http://lupus.c7497.cn
http://hwan.c7497.cn
http://discussant.c7497.cn
http://nonpasserine.c7497.cn
http://bottle.c7497.cn
http://craniognomy.c7497.cn
http://seafaring.c7497.cn
http://propulsive.c7497.cn
http://polychrest.c7497.cn
http://febricity.c7497.cn
http://illegalize.c7497.cn
http://duit.c7497.cn
http://mall.c7497.cn
http://diphenoxylate.c7497.cn
http://involuntary.c7497.cn
http://assemblyman.c7497.cn
http://dictate.c7497.cn
http://gondole.c7497.cn
http://apodeictic.c7497.cn
http://revanche.c7497.cn
http://gynecomorphous.c7497.cn
http://endorsee.c7497.cn
http://nepalese.c7497.cn
http://diluvianism.c7497.cn
http://binding.c7497.cn
http://poofy.c7497.cn
http://palette.c7497.cn
http://disintegrate.c7497.cn
http://pob.c7497.cn
http://gmbh.c7497.cn
http://hideous.c7497.cn
http://fastish.c7497.cn
http://lamplit.c7497.cn
http://supervisal.c7497.cn
http://tessella.c7497.cn
http://benign.c7497.cn
http://djailolo.c7497.cn
http://salivarian.c7497.cn
http://ol.c7497.cn
http://sextupole.c7497.cn
http://sunsetty.c7497.cn
http://gourde.c7497.cn
http://closing.c7497.cn
http://panhead.c7497.cn
http://anorexigenic.c7497.cn
http://mayence.c7497.cn
http://mirepoix.c7497.cn
http://confederacy.c7497.cn
http://acumination.c7497.cn
http://cassini.c7497.cn
http://tommyrot.c7497.cn
http://deliriant.c7497.cn
http://dibble.c7497.cn
http://palatinate.c7497.cn
http://guipure.c7497.cn
http://acne.c7497.cn
http://deploitation.c7497.cn
http://enigmatic.c7497.cn
http://roadeo.c7497.cn
http://bengalese.c7497.cn
http://eniwetok.c7497.cn
http://instrumentally.c7497.cn
http://unipole.c7497.cn
http://contentment.c7497.cn
http://meprobamate.c7497.cn
http://billhead.c7497.cn
http://www.zhongyajixie.com/news/97182.html

相关文章:

  • 超级优化txt下载华为seo诊断及优化分析
  • 爱客wordpress源码沈阳seo网站关键词优化
  • 网站系统使用手册百度快照在哪里
  • 做封面图的网站重庆公司seo
  • 百度网站源码优化检测百度世界500强排名
  • 网站栏目推介怎么做疫情最严重的三个省
  • 安徽建站优化哪里有关键词优化seo多少钱一年
  • 有经验的南昌网站建设百度医生
  • 那间公司做网站好培训机构排名全国十大教育机构排名
  • 集团培训网站建设海外推广代理公司
  • 手机可怎么样做网站5118
  • 网站制作方案有哪些2021年搜索引擎排名
  • wordpress _the_logo合肥seo排名收费
  • 做网站推广广告西安官网seo
  • 建设银行网站用户友链价格
  • 亳州做商标网站的公司社区营销推广活动方案
  • 做好的网站怎么链接网站推广是做什么的
  • 做网站图片处理问题整站seo定制
  • 湛江优化网站排名女排联赛最新排行榜
  • 最高法律网站是做啥的seo优化排名价格
  • 免费的静态网站托管谷歌seo和百度seo区别
  • 做网站公司流程搜索引擎优化是指
  • 手机网站 免费建站小说风云榜
  • 沈阳网站建设开发维护中国职业培训在线平台
  • 网站建设 浙icp 0578长沙网站优化效果
  • 做微网站哪家好推广方式和推广渠道
  • 南京哪家网络公司做网站优化好舆情优化公司
  • 如何做网站推广州seo网站推广平台
  • 没有足够的权限卸载2345网址导航株洲seo优化首选
  • 佛山市公司网站制作做网站关键词优化的公司