pd_ds中的hash

前言

在c++的STL中,提供了一种hash函数,其用法和map是几乎一样的,但是速度却能快接近一倍

使用方法

需要的头文件

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;

函数声明方式

cc_hash_table<int,bool>h;
gp_hash_table<int,bool>h;

cc_hash_table是拉链法

gp_hash_table是查探法

查探法要快一些,个人推荐用查探法。

实测

pd_ds中的hash