priority_queue member function
没有优先队列的dijkstra不算真的dijkstra
所以我又回来补常识了
<1>priority_queue::emplace
<7>priority_queue::top
// priority_queue::emplace
#include <iostream> // std::cout
#include <queue> // std::priority_queue
#include <string> // std::string int main ()
{
std::priority_queue<std::string> mypq; mypq.emplace("orange");
mypq.emplace("strawberry");
mypq.emplace("apple");
mypq.emplace("pear"); std::cout << "mypq contains:";
while (!mypq.empty())
{
std::cout << ' ' << mypq.top();
mypq.pop();
}
std::cout << '\n'; return ;
}
//Ooutput:mypq contains: strawberry pear orange apple
<2>priority_queue::empty
<3>priority_queue::pop
<4>priority_queue::push
// priority_queue::push/pop
#include <iostream> // std::cout
#include <queue> // std::priority_queue int main ()
{
std::priority_queue<int> mypq; mypq.push();
mypq.push();
mypq.push();
mypq.push(); std::cout << "Popping out elements...";
while (!mypq.empty())
{
std::cout << ' ' << mypq.top();
mypq.pop();
}
std::cout << '\n'; return ;
}
//Output:Popping out elements... 100 40 30 25
<5>priority_queue::size
<6>priority_queue::swap
// priority_queue::swap
#include <iostream> // std::cout
#include <queue> // std::priority_queue int main ()
{
std::priority_queue<int> foo,bar;
foo.push (); foo.push(); foo.push();
bar.push (); bar.push(); foo.swap(bar); std::cout << "size of foo: " << foo.size() << '\n';
std::cout << "size of bar: " << bar.size() << '\n'; return ; /*Output:
size of foo: 2
size of bar: 3*/
然后还有个自定义排序来着,到时候再摸。
priority_queue member function的更多相关文章
- Thinkphp---------Call to a member function free_result() on a non-object
1.平时用框架用久了,直接执行原生的sql反而做起来反应迟钝了.今天遇到一个问题,就是直接执行一个添加的sql语句,然后我用了TP框架的M()->query();方法.运行以后,会报Call t ...
- :( Call to a member function Table() on a non-object 错误位置
:( Call to a member function Table() on a non-object 错误位置 $Model不是模板,是你自己先前链接数据库返回的对象...我的是改为$Form
- Fatal error: Call to a member function bind_param() on a non-object in
今天在练习 mysql是出现错误: Fatal error: Call to a member function bind_param() on a non-object in 解决步骤: 1. ...
- ECmall错误:Call to a member function get_users_count() on a non-object
问题描述: 在后台添加了一个app报错:Call to a member function get_users_count()Fatal error: Call to a member functio ...
- magento后台 Fatal error: Call to a member function getId() on a non-object in错误
后台分类管理出现错误 Fatal error: Call to a member function getId() on a non-object in 在数据库中运行以下sql语句 INSERT I ...
- Function语义学之member function
之前我们讲过编译器会对 nonmember functions 进行怎样的扩充和该写,今天我们来讲一下 member functions 函数调用方式 一.Nonstatic Member Funct ...
- Timer.4 - Using a member function as a handler
In this tutorial we will see how to use a class member function as a callback handler. The program s ...
- C++ - 模板类模板成员函数(member function template)隐式处理(implicit)变化
模板类模板成员函数(member function template)隐式处理(implicit)变化 本文地址: http://blog.csdn.net/caroline_wendy/articl ...
- About The Order of The Declarations And Definition When Making a Member Function a Friend.关于使类成员成为另一个类友元函数的声明顺序和定义。
If only member function clear of WindowMgr is a friend of Screen, there are some points need to note ...
随机推荐
- matlab中setdiff
源自:http://www.w2bc.com/Article/16709 matlab中setdiff()函数作用:判断2个数组中不同元素 c = setdiff(A, B) 返回在A中有,而B中没有 ...
- 2019牛客暑期多校训练营(第八场)A 单调栈
题意 给一个\(n*m\)的01矩阵,找有多少个全1子矩阵不被其他全1子矩阵包括. 分析 用单调栈找到的全1子矩阵是不能向上扩展和向右扩展的,只需判断该子矩阵能否向左和向下扩展,若四个方向都不能扩展, ...
- Linux可变参数打印日志(二)
#include<stdio.h> #include<stdlib.h> #include<stdarg.h> #include<string.h> # ...
- Centos 7自定义屏幕分辨率
$ xrandrScreen 0: minimum 1 x 1, current 1680 x 900, maximum 8192 x 8192Virtual1 connected primary 1 ...
- P1598 垂直柱状图
输入格式: 四行字符,由大写字母组成,每行不超过100个字符 输出格式: 由若干行组成,前几行由空格和星号组成,最后一行则是由空格和字母组成的.在任何一行末尾不要打印不需要的多余空格.不要打印任何空行 ...
- 「CF442C」 Artem and Array
题目链接 戳我 \(Solution\) 观察发现如果一个数两边都比他大,删掉他可以保证最优,这个应该是显然的.这个东西用单调栈维护一下,最后剩下的就是个单调递减或单调递增的数列,从小到大排个序取前面 ...
- css三类选择器 用法 引用
css(层叠样式表): css用法:选择符{样式属性:取值;...} css选择器的分类: ①:标签选择器,such as:p{attribute:value;},p为标签选择器的name,该页面中所 ...
- JS基础_使用工厂方法创建对象
创建一个对象 var obj={ name:"hhh", age:28, gender:"男", say:function(){ console.log(&qu ...
- WorkStation 虚拟机迁移到 ESXi
将Workstation的vmdk文件导入到Esxi. 提示如题错误提示. 无法打开磁盘 scsi0:0: 磁盘类型 7 不受支持或无效.请确保磁盘已导入. 在VMware Workstation,V ...
- ubuntu 18.04 64bit下如何源码编译安装anbox
1. 准备工作 1.1 安装gcc 7.x版本 sudo apt-get install gcc-7 -y 1.2 安装依赖的库及其工具 sudo apt install build-essentia ...