关于 pbds 哈希表
  • 板块学术版
  • 楼主Laoshan_PLUS
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/8/20 15:59
  • 上次更新2024/8/20 17:37:45
查看原帖
关于 pbds 哈希表
498837
Laoshan_PLUS楼主2024/8/20 15:59

请问 pbds 里面的 cc_hash_table 和 gp_hash_table 是不是都比 unordered_map 要快,在底层实现方面。

(我们校内 OJ 的一道题用 umap TLE 30pts,用 gp_hash_table 直接 AC。)

(不是哈希函数的问题,自己手打的哈希函数加上去没有任何帮助。)

const auto RAND = chrono::high_resolution_clock::now().time_since_epoch().count();
// 不论是这个
struct hh {
    static ull splitmix64(ull x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    ull operator()(ull x) const {
        static const ull FIXED_RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// 还是这个
struct hh {
    ull operator () (const ull x) const {
    	return (x >> 32) ^ x ^ RAND;
	}
};

// 都不行。
2024/8/20 15:59
加载中...