Skip to content

Commit 3748061

Browse files
authored
Merge pull request Snailclimb#153 from Flyonsnow/master
FIX:统一 loadFactor 名称为加载因子, 为resize中的注释添加//
2 parents 29b9857 + 5412af1 commit 3748061

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Java相关/HashMap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneabl
9090
transient int modCount;
9191
// 临界值 当实际大小(容量*填充因子)超过临界值时,会进行扩容
9292
int threshold;
93-
// 填充因子
93+
// 加载因子
9494
final float loadFactor;
9595
}
9696
```
9797
- **loadFactor加载因子**
9898

99-
loadFactor加载因子是控制数组存放数据的疏密程度,loadFactor越趋近于1,那么 数组中存放的数据(entry)也就越多,也就越密,也就是会让链表的长度增加,load Factor越小,也就是趋近于0,
99+
loadFactor加载因子是控制数组存放数据的疏密程度,loadFactor越趋近于1,那么 数组中存放的数据(entry)也就越多,也就越密,也就是会让链表的长度增加,loadFactor越小,也就是趋近于0,数组中存放的数据(entry)也就越少,也就越稀疏。
100100

101101
**loadFactor太大导致查找元素效率低,太小导致数组的利用率低,存放的数据会很分散。loadFactor的默认值为0.75f是官方给出的一个比较好的临界值**
102102

@@ -401,7 +401,7 @@ final Node<K,V>[] resize() {
401401
else if (oldThr > 0) // initial capacity was placed in threshold
402402
newCap = oldThr;
403403
else {
404-
signifies using defaults
404+
// signifies using defaults
405405
newCap = DEFAULT_INITIAL_CAPACITY;
406406
newThr = (int)(DEFAULT_LOAD_FACTOR * DEFAULT_INITIAL_CAPACITY);
407407
}

0 commit comments

Comments
 (0)