Update Java 容器.md

补充 HashMap 扩容时桶下标变化的示意图。
This commit is contained in:
CyC2018
2026-10-25 19:34:23 +08:00
parent 734115be54
commit 5422b53ef0
3 changed files with 100 additions and 0 deletions
+2
View File
@@ -754,6 +754,8 @@ new capacity : 00100000
- 为 0,那么 hash%00010000 = hash%00100000,桶位置和原来一致;
- 为 1,hash%00100000 = hash%00010000 + 16,桶位置是原位置 + 16。
<div align="center"> <img src="pics/hashmap-resize.png" width="560px"/> </div><br>
#### 7. 计算数组容量
HashMap 构造函数允许用户传入的容量不是 2 的 n 次方,因为它可以自动地将传入的容量转换为 2 的 n 次方。
Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB