- 想要实现一个性能优异的哈希表,需要注意两个关键点
- 哈希函数
- 完美哈希
- 哈希函数的输出范围大于输入范围
- 不均匀哈希
- 尽量避免
- 完美哈希
- 冲突解决方法
- 开放寻址法(线性探测法)
- 拉链法,拉链表
- 哈希函数
map数据结构 ```go type hmap struct { count int //哈希元素数量 flags uint8
B uint8 // buckets数量 noverflow uint16 hash0 uint32 //哈希的种子buckets unsafe.Pointer oldbuckets unsafe.Pointer 扩容时 nevacuate uintptr
extra *mapextra }
type mapextra struct { overflow []bmap oldoverflow []bmap nextOverflow *bmap } ```
