Merge pull request #769 from ruiHut/hashmap

#768 issue Java 容器 JDK.1.7 HashMap 扩容源代码描述
This commit is contained in:
CyC2018 2019-08-18 23:37:20 +08:00 committed by GitHub
commit 7ae8fc3961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -650,7 +650,7 @@ static int indexFor(int h, int length) {
| capacity | table 的容量大小默认为 16需要注意的是 capacity 必须保证为 2 n 次方| | capacity | table 的容量大小默认为 16需要注意的是 capacity 必须保证为 2 n 次方|
| size | 键值对数量 | | size | 键值对数量 |
| threshold | size 的临界值 size 大于等于 threshold 就必须进行扩容操作 | | threshold | size 的临界值 size 大于等于 threshold 就必须进行扩容操作 |
| loadFactor | 装载因子table 能够使用的比例threshold = capacity * loadFactor| | loadFactor | 装载因子table 能够使用的比例threshold = (int)(newCapacity * loadFactor)|
```java ```java
static final int DEFAULT_INITIAL_CAPACITY = 16; static final int DEFAULT_INITIAL_CAPACITY = 16;