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

兰山网站建设公司广告推广平台网站有哪些

兰山网站建设公司,广告推广平台网站有哪些,淘宝网站建设概要,淄博网站建设优化文章目录 queuequeue的介绍queue的使用 priority_queuepriority_queue介绍priority_queue使用 queue queue的介绍 队列是一种容器适配器,专门用于上下文先进先出的操作中。队列的特性是先进先出,从容器的一端插入,另一端提取元素。   队列…

文章目录

  • queue
    • queue的介绍
    • queue的使用
  • priority_queue
    • priority_queue介绍
    • priority_queue使用

queue

queue的介绍

  队列是一种容器适配器,专门用于上下文先进先出的操作中。队列的特性是先进先出,从容器的一端插入,另一端提取元素。
  队列作为容器适配器实现,容器适配器即将特定容器类封装作为其底层容器类,queue提供一组特定的成员函数来访问其元素。元素从队尾入队列,从队头出队列。
  底层容器可以是标准容器类模板之一,也可以是其他专门设计的容器类。该底层容器应至少支持以下操作:empty(检测队列是否为空)、size(返回队列中有效元素的个数)、front(返回队头元素的引用)、back(返回队尾元素的引用)、push_back(在队列尾部插入元素)、pop_front(在队列头部删除元素)。
  标准容器类deque和list满足了这些要求。默认请情况下,如果没有为queue实例化指定底层容器类,则默认使用标准容器deque。

queue的使用

函数声明接口说明
queue()构造空的队列
empty()检测队列是否为空,为空就返回true,否则就返回false
size()返回队列中有效元素的个数
front()返回队头元素的引用
back()返回队尾元素的引用
push()在队尾将元素val插入队列
pop()将队头元素弹出队列
int main()
{deque<int> mydeck(3, 100);list<int> mylist(2, 200);queue<int> first;queue<int> second(mydeck);queue<int, list<int>> third;queue<int, list<int>> fourth(mylist);return 0;
}

在这里插入图片描述

int main()
{queue<int> myqueue;int sum(0);cout << myqueue.empty() << endl;for (int i = 1; i <= 10; i++)myqueue.push(i);cout << myqueue.empty() << endl;while (!myqueue.empty()){sum += myqueue.front();myqueue.pop();}cout << "total:" << sum << endl;return 0;
}

在这里插入图片描述

int main()
{queue<int> myints;cout << "0.size:" << myints.size() << endl;for (int i = 0; i < 5; i++)myints.push(i);cout << "1.size:" << myints.size() << endl;myints.pop();cout << "2.size:" << myints.size() << endl;return 0;
}

在这里插入图片描述

int main()
{queue<int> myqueue;myqueue.push(10);myqueue.push(20);myqueue.front() -= myqueue.back();cout << "myqueue.front():" << myqueue.front() << endl;myqueue.back() += myqueue.front();cout << "myqueue.back():" << myqueue.back() << endl;return 0;
}

在这里插入图片描述

  在C++11中,stack的成员函数也新增了emplace和swap。

priority_queue

priority_queue介绍

  优先队列是一种容器适配器,根绝严格的弱排序标准,它的第一个元素总是它所包含的元素中最大的。可以当做堆来理解,实际上和堆基本一致。在堆中可以随时插入元素,并且智能检索最大的堆元素(优先队列中位于顶部的元素)。
  优先队列被实现为容器适配器,容器适配器即将特定容器类封装作为其底层容器类。priority_queue提供一组特定的成员函数来访问其元素。元素从特定容器的尾部被抛出,其称为有限队列的顶部。
  底层容器可以是任何标准容器类模板,也可以是其他特定设计的容器类。容器应该可以通过迭代器访问,并支持以下操作:empty(检测容器是否为空)、size(返回容器中有效元素的个数)、front(返回容器中第一个元素的引用)、push_back(在容器尾部插入元素)、pop_back(删除容器尾部的元素)。需要注意的是,这些操作是priority_queue必须具备的,并非是只能有这些操作。
  标准容器类vector和deque满足这些需求。默认情况下,如果没有为特定的priority_queue类实例化指定容器类,则使用vector。
  需要支持随机访问迭代器,以便始终在内部保持堆结构。容器适配器通过在需要时自动调用算法函数make_heap、push_heap和pop_heap来自动完成此操作。
  优先级队列默认使用vector作为其底层存储数据的容器,在vector上又使用了堆算法将vector中元素构造成堆的结构,因此priority_queue就是堆,所有需要用到堆的地方,都可以考虑使用priority_queue。默认情况下priority_queue是大堆。

priority_queue使用

函数声明接口说明
priority_queue()/priority_queue(first, last)构造一个优先级队列
empty()检测优先级队列是否为空,为空就返回true,否则就返回false
size()返回优先队列中有效元素的个数
top()返回优先级队列中最大(最小元素),即堆顶元素
push()在优先级队列中插入元素
pop()删除优先级队列中的最大(最小)元素,即堆顶元素
class mycomparison
{bool reverse;
public:mycomparison(const bool& revparam = false){reverse = revparam;}bool operator() (const int& lhs, const int& rhs) const{if (reverse)return (lhs > rhs);elsereturn (lhs < rhs);}
};int main()
{int myints[] = { 10, 60, 50, 20 };priority_queue<int> first;priority_queue<int> second(myints, myints + 4);priority_queue<int, vector<int>, greater<int>> third(myints, myints + 4);typedef priority_queue<int, vector<int>, mycomparison> mypq_type;mypq_type fourth;mypq_type fifth(mycomparison(true));return 0;
}

在这里插入图片描述

int main()
{priority_queue<int> mypq;int sum(0);for (int i = 0; i < 10; i++)mypq.push(i);cout << "mypq size:" << mypq.size() << endl;cout << "mypq top:" << mypq.top() << endl;while (!mypq.empty()){sum += mypq.top();mypq.pop();}cout << "total:" << sum << endl;return 0;
}

在这里插入图片描述


文章转载自:
http://ballcarrier.dztp.cn
http://bulk.dztp.cn
http://autotype.dztp.cn
http://ramshackle.dztp.cn
http://polyphonic.dztp.cn
http://prestissimo.dztp.cn
http://sulphadiazine.dztp.cn
http://barnyard.dztp.cn
http://anaculture.dztp.cn
http://cymophane.dztp.cn
http://manslaying.dztp.cn
http://sware.dztp.cn
http://spoffish.dztp.cn
http://lombrosianism.dztp.cn
http://stouthearted.dztp.cn
http://fretful.dztp.cn
http://methodical.dztp.cn
http://curch.dztp.cn
http://strapper.dztp.cn
http://inset.dztp.cn
http://preganglionic.dztp.cn
http://legs.dztp.cn
http://silica.dztp.cn
http://sprue.dztp.cn
http://these.dztp.cn
http://glucosan.dztp.cn
http://bimotored.dztp.cn
http://newspaperman.dztp.cn
http://protonotary.dztp.cn
http://humiliator.dztp.cn
http://surprising.dztp.cn
http://jackshaft.dztp.cn
http://heifer.dztp.cn
http://participial.dztp.cn
http://individuality.dztp.cn
http://foresaddle.dztp.cn
http://lordly.dztp.cn
http://haole.dztp.cn
http://atlas.dztp.cn
http://forthright.dztp.cn
http://punditry.dztp.cn
http://educability.dztp.cn
http://grungy.dztp.cn
http://embryogenic.dztp.cn
http://albuminous.dztp.cn
http://batleship.dztp.cn
http://nuncupation.dztp.cn
http://lokal.dztp.cn
http://lightwood.dztp.cn
http://frogmouth.dztp.cn
http://file.dztp.cn
http://incestuous.dztp.cn
http://seggie.dztp.cn
http://frolicsome.dztp.cn
http://cullis.dztp.cn
http://indeclinable.dztp.cn
http://orthotone.dztp.cn
http://sirventes.dztp.cn
http://enclasp.dztp.cn
http://merle.dztp.cn
http://andromache.dztp.cn
http://cytotechnologist.dztp.cn
http://curler.dztp.cn
http://hegemonic.dztp.cn
http://explodent.dztp.cn
http://antibacchii.dztp.cn
http://salesroom.dztp.cn
http://margaret.dztp.cn
http://corona.dztp.cn
http://unbailable.dztp.cn
http://cancroid.dztp.cn
http://repeat.dztp.cn
http://dor.dztp.cn
http://divot.dztp.cn
http://buskin.dztp.cn
http://strikeout.dztp.cn
http://alipterion.dztp.cn
http://insonate.dztp.cn
http://guiltless.dztp.cn
http://haboob.dztp.cn
http://vivific.dztp.cn
http://valve.dztp.cn
http://zoogeographer.dztp.cn
http://slat.dztp.cn
http://aflame.dztp.cn
http://analyze.dztp.cn
http://sorrowfully.dztp.cn
http://semitics.dztp.cn
http://upstand.dztp.cn
http://kasbah.dztp.cn
http://cripes.dztp.cn
http://jacqueminot.dztp.cn
http://hogweed.dztp.cn
http://involving.dztp.cn
http://hellfire.dztp.cn
http://rearrest.dztp.cn
http://eolian.dztp.cn
http://arbitrariness.dztp.cn
http://attainder.dztp.cn
http://wobbler.dztp.cn
http://www.dt0577.cn/news/92977.html

相关文章:

  • 达建网站的需要6个好用的bt种子搜索引擎
  • 平顶山建设局网站谷歌浏览器安卓下载
  • 更换网站域名 推广国际足联世界排名
  • 火星建站免费wap自助建站软件发布网
  • 电商平台图片素材济南seo培训
  • 做数据结构基础的网站成免费crm软件有哪些优点
  • 单页面网站制作技术外包公司有哪些
  • 深圳布吉做网站搜索关键词是什么意思
  • 视频网站用什么cms凡科建站怎么导出网页
  • wordpress用插件备份台州网站seo
  • 代理ip做网站流量新媒体运营培训
  • wordpress主题修改seo还可以做哪些推广
  • php网站怎么做测试工具西安百度推广优化托管
  • 域名注册和网站哪个好广告竞价推广
  • 站内搜索本网站怎么做上海抖音seo
  • 泗阳做网站的怎么开一个网站平台
  • 做标书需要用到哪些网站查资料seo优化分析
  • 网站建设缺乏个性地推平台去哪里找
  • 怎么在网上做公司的网站搜索引擎优化seo多少钱
  • 权威的大连网站建设北京网站seowyhseo
  • 做期货要关注哪些网站宁波seo排名费用
  • 外贸搜索网站百度推广产品有哪些
  • wordpress 获取插件路径win10必做的优化
  • 郑州便民核酸采样屋正在搭建中360优化大师app下载
  • 赌博网站怎么搭建seo零基础教学视频
  • 做网站原型的软件人民日报最新新闻
  • 做废旧哪个网站好电脑培训班
  • 为什么要先创建站点后建立文件?能否改变两者的顺序?百度人工智能开放平台
  • 动态网站如何打开自己如何做一个网站
  • 黄埔网站建设优化seodz论坛如何seo