• unordered_map 的火车头


    #include <functional>
    template <typename T>
    inline void hash_combine(std::size_t &seed, const T &val) {
        seed ^= std::hash<T>()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    }
    template <typename T> inline void hash_val(std::size_t &seed, const T &val) {
        hash_combine(seed, val);
    }
    template <typename T, typename... Types>
    inline void hash_val(std::size_t &seed, const T &val, const Types &... args) {
        hash_combine(seed, val);
        hash_val(seed, args...);
    }
    
    template <typename... Types>
    inline std::size_t hash_val(const Types &... args) {
        std::size_t seed = 0;
        hash_val(seed, args...);
        return seed;
    }
    
    struct pair_hash {
        template <class T1, class T2>
        std::size_t operator()(const std::pair<T1, T2> &p) const {
            return hash_val(p.first, p.second);
        }
    };
    
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    
    int main() {
        unordered_map<pair<ll, ll>, ll, pair_hash> slopeCount;
        unordered_set<pair<ll, ll>, pair_hash> seen;
        return 0;
    }
    rush!
  • 相关阅读:
    中译英26
    listen 59
    Speaking 1
    listen 58
    listen 57
    中译英25
    listen 56
    2018.2.27 RF module distance test part I
    中译英24
    第二章、PyQt5应用构建详细过程介绍
  • 原文地址:https://www.cnblogs.com/LH2000/p/14407030.html
Copyright © 2020-2023  润新知