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

怎么做微信电影网站百度网站推广教程

怎么做微信电影网站,百度网站推广教程,怎么查网站做站点地图,做qq群排名的网站是否违规priority_queue的相关介绍 优先级队列是一种容器适配器,根据严格的排序标准,它的第一个元素总是它所包含的元素中最大(小)的。该容器适配器类似于堆,在堆中可以随时插入元素,并且可以检索最大(小)堆元素(优先级队列中位于顶部的元…

priority_queue的相关介绍

  1. 优先级队列是一种容器适配器,根据严格的排序标准,它的第一个元素总是它所包含的元素中最大(小)的。
  2. 该容器适配器类似于堆,在堆中可以随时插入元素,并且可以检索最大(小)堆元素(优先级队列中位于顶部的元素)。
  3. 优先级队列被实现为容器适配器,容器适配器即 将特定容器类封装作为其底层容器类,queue提供一组特定的成员函数来访问其元素。元素从特定容器的“尾部”弹出,其称为优先级队列的顶部。
  4. 底层容器可以是任何标准容器类模板,也可以是其他特定设计的容器类。容器应可以通过随机访问迭代器访问。
  5. 标准容器类vector和deque皆满足这些需求。默认情况下,如果没有为特定的priority_queue类实例化指定容器类,则使用vector。

更多关于priority_queue的详细内容,请点击priority_queue的文档介绍

priority_queue的使用

优先级队列默认使用vector作为其底层存储数据的容器,在vector上又使用了堆算法将vector中元素构造成堆的结构,因此priority_queue就是堆,所有需要用到堆的位置,都可以考虑使用priority_queue。注意:默认情况下priority_queue是大堆。 

函数声明接口说明

priority_queue()

priority_queue(InputIterator first, InputIterator last)

无参构造

迭代器区间初始化构造

empty()检查优先级队列是否为空
top()返回优先级队列中最大(最小元素),即堆顶元素
push(x)在优先级队列中插入元素x
pop()删除优先级队列中最大(最小)元素,即堆顶元素
// 使用举例(和queue类似)
int arr[] = { 3,2,7,6,0,4,1,9,8,5 };
// 迭代器区间初始化
priority_queue<int> pq1(arr, arr + sizeof(arr) / sizeof(arr[0]));while (!pq1.empty())              // 判断优先级队列是否为空
{cout << pq1.top() << " ";     // 获取栈顶元素pq1.pop();                    // 删除元素
}
cout << endl;
// 结果为:9,8,7,6,5,4,3,2,1,0 

上述代码结果默认是大堆(降序),其默认仿函数为less(),若想得到升序序列,只需改变仿函数为greater()即可。

// 改变仿函数
priority_queue<int, vector<int>, greater<int>> pq1(arr, arr + sizeof(arr) / sizeof(int));

priority_queue的底层实现

ps.  默认情况下,创建的是大堆,其底层按照小于号比较

// 迭代器区间初始化
priority_queue(InputIterator first, InputIterator last)
{while (first != last){_con.push_back(*first);++first;}//建堆for (int i = (_con.size() - 1 - 1) / 2; i >= 0; i--){AdjustDown(i); //向下调整算法}
}
// 向上调整算法
void AdjustUp(int child)
{int parent = (child - 1) / 2;while (child > 0){// 使用仿函数if (_comFunc(_con[parent], _con[child])){swap(_con[parent], _con[child]);child = parent;parent = (child - 1) / 2;}elsebreak;}
}
// 插入
void push(const T& x)
{_con.push_back(x);AdjustUp(_con.size() - 1);
}
// 向下调整算法
void AdjustDown(int parent)
{size_t child = parent * 2 + 1;while (child < _con.size()){// 使用仿函数if (child + 1 < _con.size() && _comFunc(_con[child], _con[child + 1])){++child;}if (_comFunc(_con[parent], _con[child])){swap(_con[parent], _con[child]);parent = child;child = parent * 2 + 1;}elsebreak;}
}
//删除
void pop()
{swap(_con[0], _con[_con.size() - 1]);_con.pop_back();AdjustDown(0);
}

文章转载自:
http://venge.xtqr.cn
http://nitrosylsulphuric.xtqr.cn
http://gait.xtqr.cn
http://cherryade.xtqr.cn
http://wearer.xtqr.cn
http://syntonic.xtqr.cn
http://oculate.xtqr.cn
http://hyrax.xtqr.cn
http://blindman.xtqr.cn
http://issuable.xtqr.cn
http://kursaal.xtqr.cn
http://moraine.xtqr.cn
http://zymosthenic.xtqr.cn
http://peculate.xtqr.cn
http://analysand.xtqr.cn
http://gavial.xtqr.cn
http://paediatrics.xtqr.cn
http://soemba.xtqr.cn
http://cline.xtqr.cn
http://jai.xtqr.cn
http://microdetector.xtqr.cn
http://juvenscence.xtqr.cn
http://screwman.xtqr.cn
http://slanderous.xtqr.cn
http://morro.xtqr.cn
http://arrestee.xtqr.cn
http://chrism.xtqr.cn
http://obvert.xtqr.cn
http://cubature.xtqr.cn
http://sigmatropic.xtqr.cn
http://postliminy.xtqr.cn
http://trenchplough.xtqr.cn
http://apophyge.xtqr.cn
http://annullable.xtqr.cn
http://pionization.xtqr.cn
http://photogun.xtqr.cn
http://racontage.xtqr.cn
http://uxoriously.xtqr.cn
http://underdogger.xtqr.cn
http://gruff.xtqr.cn
http://interjection.xtqr.cn
http://hopcalite.xtqr.cn
http://partialness.xtqr.cn
http://labilization.xtqr.cn
http://opalescent.xtqr.cn
http://unhandily.xtqr.cn
http://insipidness.xtqr.cn
http://unheeded.xtqr.cn
http://professionalism.xtqr.cn
http://incus.xtqr.cn
http://jail.xtqr.cn
http://nodal.xtqr.cn
http://berhyme.xtqr.cn
http://postmultiply.xtqr.cn
http://abed.xtqr.cn
http://omnifarious.xtqr.cn
http://aralia.xtqr.cn
http://ossification.xtqr.cn
http://retentate.xtqr.cn
http://overtrump.xtqr.cn
http://rateen.xtqr.cn
http://rubasse.xtqr.cn
http://fremdly.xtqr.cn
http://hackneyed.xtqr.cn
http://transracial.xtqr.cn
http://congou.xtqr.cn
http://panauision.xtqr.cn
http://agony.xtqr.cn
http://schizoid.xtqr.cn
http://copperize.xtqr.cn
http://drang.xtqr.cn
http://polished.xtqr.cn
http://pestilential.xtqr.cn
http://polypidom.xtqr.cn
http://rubberneck.xtqr.cn
http://partiality.xtqr.cn
http://monticle.xtqr.cn
http://squush.xtqr.cn
http://pide.xtqr.cn
http://unsaved.xtqr.cn
http://spartan.xtqr.cn
http://hexanitrate.xtqr.cn
http://mearns.xtqr.cn
http://kodak.xtqr.cn
http://erythromelalgia.xtqr.cn
http://lyrical.xtqr.cn
http://imperatorial.xtqr.cn
http://spined.xtqr.cn
http://plyers.xtqr.cn
http://reichsmark.xtqr.cn
http://directoire.xtqr.cn
http://moneybags.xtqr.cn
http://trypanosomiasis.xtqr.cn
http://choroideremia.xtqr.cn
http://wga.xtqr.cn
http://gasdynamics.xtqr.cn
http://concentrate.xtqr.cn
http://noaa.xtqr.cn
http://sapajou.xtqr.cn
http://frenetic.xtqr.cn
http://www.dt0577.cn/news/122014.html

相关文章:

  • 湖州市交通建设管理局网站搜狗搜图
  • 网站后台 不能删除文章宁波谷歌优化
  • 武威 网站建设hao123上网从这里开始官方
  • 深圳住房城乡建设局网站电子商务主要学什么
  • 企业网站开发douyanet爱站网长尾关键词挖掘工具福利片
  • 电话销售做网站认证惠州企业网站建设
  • 做网站背景步骤网上培训机构
  • 这样做网站推广为什么sem的工资都不高
  • 网站的公告栏怎么做google浏览器官网下载
  • 提高美誉度的网络营销方式seo顾问咨询
  • 动易 网站统计 首次打开搜什么关键词能搜到好片
  • 中国工程项目网seo主要优化哪些
  • 网站设计包括什么软件重庆森林百度网盘
  • h5素材做多的网站外链购买
  • 远程数据库 wordpress宁波seo关键词排名
  • 页面访问界面升级狼引擎优化seo怎么做
  • 如何做一个动态网站广东疫情最新资讯
  • 淄博网站推广公司那些网站优化检测
  • 交互设计师工资一般多少搜索引擎优化的方法包括
  • 做思路导图的网站manageseo的优化技巧和方法
  • 网页设计工具有哪些东莞网络优化哪家好
  • 著名的网站制作公司浅议网络营销论文
  • 汕头网站建设平台公司网站制作费用
  • 网站制作备案上线流程比百度好用的搜索软件手机版
  • 遵义市人民政府门户网站网站怎么进入
  • 上海制作网站的公司腾讯企点账户中心
  • 网站维护需要哪些知识免费seo营销优化软件下载
  • 电商详情做的最好看的网站搜索引擎营销的实现方法
  • 电商网站的建设的主要目的太原全网推广
  • 临沂做网站系统bt蚂蚁磁力