下面以 long long 型队列介绍:

Q.empty()   // 判断队列是否为空 返回ture表示空 返回false表示空      bool
Q.top() // 返回顶端元素的值 元素还在队列里 long long
Q.pop() // 删除顶端元素 void
Q.push(V) // 把 long long型的数V加入到队列里 它会制动条件V的位置 void
Q.size() // 返回队列里元素个数 unsigned int priority_queue<int,vector<int>,greater<int> > que; // 最小优先队列
priority_queue<int> que1; // 最大优先队列
priority_queue<int,vector<int>,less<int> > que1; // 最大优先队列 ( 注意在两个尖括号之间一定要留空格。)
priority_queue<node>que; // 结构体node自己定义 是其它类型的如long long 用最小优先队列需要从载 cmp 类 struct cmp{ // 整形最小优先队列
bool operator()(const int i,const int j){
return i>j;
}
};
priority_queue<int,vector<int>,cmp>que; struct cmp{ // long long 型最小优先队列
bool operator()(const long long i,const long long j){
return i>j;
}
};
priority_queue<int,vector<long long>,cmp> Q; struct cmp{ // string表示整数最小最优队列的重载
bool operator()(const string &i,const string &j){
int len1=i.length(),len2=j.length();
if(len1==len2)return i.compare(j)>;
return len1>len2;
}
};
priority_queue<int,vector<string>,cmp> Q; bool cmpe(string i,string j){ // 从大数到小数的排序重载
int len1=i.length(),len2=j.length();
if(len1==len2)return i.compare(j)>;
return len1 > len2;
}
sort(a+,a++,cmpe);

STL之priority_queue的更多相关文章

  1. STL之priority_queue(优先队列)

    priority_queue是一个容器适配器,在这个容器里第一个数据元素是最大的.它的使用场景是什么样:如果12306抢票,为什么黄牛能抢这么多票,感觉12306那边的请求队列是一个优先队列,黄牛的请 ...

  2. STL中priority_queue小结

    (1)为了运用priority_queue,你必须包含头文件<queue>:#include<queue> (2)在头文件中priority_queue定义如下: namesp ...

  3. C++ STL之priority_queue

    STL中的priority_queue(优先队列)是一种会按照自定义的一种方式(数据的优先级)来对队列中的数据进行动态的排序的容器,不同优先级的情况下,top()上永远是最高优先级的数据,其底层采用的 ...

  4. STL之priority_queue使用简介

    优先队列容器也是一种从一端入队,另一端出对的队列.不同于一般队列的是,队列中最大的元素总是位于队首位置,因此,元素的出对并非按照先进先出的要求,将最先入队的元素出对,而是将当前队列中的最大元素出对. ...

  5. STL 中priority_queue小结

    (1)为了运用priority_queue,你必须包含头文件<queue>:#include<queue>    (2)在头文件中priority_queue定义如下: nam ...

  6. 【转载】STL之priority_queue

    参考资料:传送门先回顾队列的定义:队列(queue)维护了一组对象,进入队列的对象被放置在尾部,下一个被取出的元素则取自队列的首部.priority_queue特别之处在于,允许用户为队列中存储的元素 ...

  7. 【STL】-priority_queue的用法

    初始化: priority_queue<int>                           maxPQ; priority_queue<int,vector<int& ...

  8. STL之priority_queue为复合结构排序

    priority_queue为复合结构排序: #include <iostream> #include <queue> using namespace std; struct ...

  9. C++ STL 优先队列 priority_queue 详解(转)

    转自https://blog.csdn.net/c20182030/article/details/70757660,感谢大佬. 优先队列 引入 优先队列是一种特殊的队列,在学习堆排序的时候就有所了解 ...

随机推荐

  1. EasyuI comboxTree 使用笔记

    继承至 $.fn.combo.defaults 和$.fn.tree.defaults.覆盖默认值$.fn.combotree.defaults. combotree结合选择控制和下拉树,类似于com ...

  2. USB_HID读写上位机VC++

    在工程属性-->链接器-->添加以下库 open 打开,close 关闭,打开后将获得reader 与writer 的handle,分别进行读写即可 #pragma once #ifdef ...

  3. 6. UIImageView 的使用

    1. UIImageView 的认识 QQ:853740091 UIImageView 继承UIView,通过他的名字我们也可以看出这个是用来显示图片的 2. 使用方法 UIImageView *im ...

  4. 把 excel 和 mysq l数据库相互转换

    不用代码轻松搞定,参考http://jingyan.baidu.com/article/fc07f9891cb56412ffe5199a.html 1.excel 转 mysql a.首先确认你的数据 ...

  5. WPF 如何画一颗心

    如何用WPF画一个心. MainWindow.xaml <Window x:Class="Heart.MainWindow" xmlns="http://schem ...

  6. C语言学习笔记二

    第二章 数组 一,定义: 数组是有序数据的结合,同一数据类型 整型数组     int arr[10]={0,1,2,4,5,6,7,8,9}; 字符数组     char str[6]={'h',' ...

  7. dir命令只显示文件名

    dir /b 就是ls -f的效果 1057 -- FILE MAPPING_web_archive.7z 2007 多校模拟 - Google Search_web_archive.7z 2083 ...

  8. git使用

    1.权限校验 首先,您的数据保存在远端服务器一份,服务器需要对您的身份进行识别,一段RAS加密字串, 启动GUI,step1:创建秘钥,generate SSHkey. step2:添加密钥:去你的代 ...

  9. Mac AppleScript 自动完成按键

    本人用AppleScript成功实现了打开锐捷app,并且在用户验证框输入我的用户密码,然后强制退出锐捷.(至于为什么这么做呢?用校园网的痛苦,一言难尽啊!) 学习以下内容,首先你要自行百度资料来学习 ...

  10. R内存管理与垃圾清理

    1.内存查看 memory.limit():查看内存大小 memory.limit(n):申请内存大小 memory.size(NA):查看内存大小 memory.size(T):查看已分配的内存 m ...