From ec0856ccfa98624574f3e2fc5015e3d09d8fd5ef Mon Sep 17 00:00:00 2001 From: iScream <983154320@qq.com> Date: Wed, 15 Mar 2023 02:18:07 +0800 Subject: [PATCH] docs(Hashing/Hash_Collision): add go part. (#395) * docs(Hashing/Hash_Collision): add go part. * docs(Hashing/Hash_Collision): add go part. * docs(Hashing/Hash_Collision): add go part. * docs(Hashing/Hash_Collision): add go part. * docs(Hashing/Hash_Collision): add go part. * Update hash_collision.md * fix context logic question * Update Go language hash table collision handling to limit each bucket to 8 entries and compare keys' high 8 bits of hash to reduce access to key-value pairs * Update hash_collision.md --------- Co-authored-by: Yudong Jin --- docs/chapter_hashing/hash_collision.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/chapter_hashing/hash_collision.md b/docs/chapter_hashing/hash_collision.md index a7c5236b3..50aad8cfa 100644 --- a/docs/chapter_hashing/hash_collision.md +++ b/docs/chapter_hashing/hash_collision.md @@ -75,3 +75,5 @@ Java 采用「链式地址」。在 JDK 1.8 之后,HashMap 内数组长度大于 64 时,长度大于 8 的链表会被转化为「红黑树」,以提升查找性能。 Python 采用「开放寻址」。字典 dict 使用伪随机数进行探测。 + + Golang 采用「链式地址」。Go 规定每个桶最多存储 8 个键值对,超出容量则连接一个溢出桶;当溢出桶过多时,会执行一次特殊的等量扩容操作,以保证性能。