zoukankan      html  css  js  c++  java
  • STL— priority_queue

    一,基操

    top: 访问队头元素

    empty: 队列是否为空

    size: 返回队列内元素个数

    push: 插入元素到队尾 (并排序)

    emplace: 原地构造一个元素并插入队列

    pop: 弹出队头元素

    swap: 交换内容 

    二,<  的重载,按照 dis 的大小升序排序

    1,

    typedef struct node    // 队列里要放的应该是 点的 id 和 distance ,而不是一条边
    {
        int id;    
        int dis;   
    node(){} node(
    int a, int b) :id(a), dis(b) {} bool operator <(const node &a)const // < 的重载 { return a.dis < dis; } }st; priority_queue <st>q;

    2,

    typedef struct node    // 队列里要放的应该是 点的 id 和 distance ,而不是一条边
    {
        int id;
        int dis;
       node(){} node(
    int a, int b) :id(a), dis(b) {} friend bool operator <(const node &a,const node &b) // < 的重载 { return a.dis > b.dis; } }st; priority_queue <st>q;

    1,2 等效,为升序

    ========== ========= ======== ======= ====== ====== ==== === == =

    连自己喜欢什么都不敢尝试的话,终究连自己都看不起自己 

  • 相关阅读:
    nginx1.9+新增tcp/udp代理stream
    mysql授权
    搭建GIT服务器
    Centos调出图形化的网络管理
    吾爱破解论坛纪念壁纸(怀念)
    VNC-tigervnc-server远程调用图形化
    Linux生成高强度密码
    Linux学习必备
    git编译
    书单
  • 原文地址:https://www.cnblogs.com/asdfknjhu/p/12596117.html
Copyright © 2011-2022 走看看