zoukankan      html  css  js  c++  java
  • 技巧汇总

    1. 修改set里面的非键值。

    用mutable来修饰这个非键值。

    举例代码:

    #include<bits/stdc++.h>
    using namespace std;
    #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout);
    #define LL long long
    #define ULL unsigned LL
    #define fi first
    #define se second
    #define pb push_back
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define lch(x) tr[x].son[0]
    #define rch(x) tr[x].son[1]
    #define max3(a,b,c) max(a,max(b,c))
    #define min3(a,b,c) min(a,min(b,c))
    typedef pair<int,int> pll;
    const int inf = 0x3f3f3f3f;
    const int _inf = 0xc0c0c0c0;
    const LL INF = 0x3f3f3f3f3f3f3f3f;
    const LL _INF = 0xc0c0c0c0c0c0c0c0;
    const LL mod =  (int)1e9+7;
    const int N = 2e5 + 100;
    struct Node{
        int l;
        mutable int v;
        bool operator < (const Node & x) const{
            return l < x.l;
        }
        Node(int a, int b): l(a), v(b){};
    };
    set<Node> st;
    int main(){
        st.insert(Node(1, 2));
        set<Node>::iterator it = st.lower_bound(Node(0, 0));
        cout << (*it).l << " " << (*it).v << endl;
        (*it).v = 3;
        cout << (*it).l << " " << (*it).v << endl;
    
        return 0;
    }
    View Code
  • 相关阅读:
    你不知道的javascript -- 数据类型
    draft.js开发富文本编辑器
    webpack4配置react开发环境
    使用yarn代替npm
    promise基础和进阶
    express route的写法
    理解es6箭头函数
    Mocha测试
    js 实现继承
    Unity3D使用经验总结 缺点篇
  • 原文地址:https://www.cnblogs.com/MingSD/p/11145113.html
Copyright © 2011-2022 走看看