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 ...
随机推荐
- TensorFlow使用记录 (十四): Multi-task to MNIST + Fashion MNIST
前言 后面工作中有个较重要的 task 是将 YOLOV3 目标检测和 LanNet 车道线检测和到一个网络中训练,特别的是,这两部分数据来自于不同的数据源.这和我之前在 caffe 环境下训练检测整 ...
- luogu4212
P4212 外太空旅行 题目描述 在人类的触角伸向银河系的边缘之际,普通人上太空旅行已经变得稀松平常了.某理科试验班有n个人,现在班主任要从中选出尽量多的人去参加一次太空旅行活动. 可是n名同学并不是 ...
- Codeforces 785 E. Anton and Permutation(分块,树状数组)
Codeforces 785 E. Anton and Permutation 题目大意:给出n,q.n代表有一个元素从1到n的数组(对应索引1~n),q表示有q个查询.每次查询给出两个数l,r,要求 ...
- 一键生成koa/koa2项目
1. npm install -g koa-generator 安装生成器 2.执行 koa mytest (koa1项目) koa2 koa2test (koa2项目) 3.进入目录 cd koa2 ...
- python3 基本数据类型转换
'''基本数据类型1:虽然python中的变量不需要声明,但使用时必须赋值 1.整形变量 2.浮点型变量 3.字符型2:可以一个给多个变量赋值,也可以多个给多个变量赋值3:python3中有6个标准数 ...
- 在CentOS 7上搭建WordPress
环境(ECS阿里云服务器) 服务器操作系统:CentOS 7.3 : 博客部署服务器:Apache HTTP: 数据库:MySql: 框架:WordPress: 步骤 一.安装 Apache HTTP ...
- 解决Maven打包提示:读取C:\Users\Administrator\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar时出错; invalid LOC header (bad signature)
1.打包情况 虽然提示读取jar包出错,但是还是能打包成功,在执行打的jar包时会报错,说找不到相关的类. 2.解决方案 从提示的路径可以找到对应的jar包,但为什么会读取错误呢?尝试着双击打开log ...
- (十)C语言之putchar、getchar
- js 处理url参数,应用导航分类
1.先上图 2.代码 html <li><a href="javascript:void(0);" data-cid = "{$v['id']}&quo ...
- smarty 模板中输出时间戳为年月日格式
日期:{:date('Y-m-d',$v['addtime'])} // $v['addtime']数据库中的时间戳 输出结果: 日期:{:date('Y-m-d H:i:s',$v['addtim ...