Skip to content

Commit 1f4f6d6

Browse files
committed
✨ Introducing new features. HashSet
1 parent eefee5c commit 1f4f6d6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

MD/collection/HashSet.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# HashSet 底层分析
2+
3+
`HashSet` 是一个不允许存储重复元素的集合,它的实现比较简单,只要理解了 `HashMap``HashSet` 就水到渠成了。
4+
5+
## 成员变量
6+
首先了解下 `HashSet` 的成员变量:
7+
8+
```java
9+
private transient HashMap<E,Object> map;
10+
11+
// Dummy value to associate with an Object in the backing Map
12+
private static final Object PRESENT = new Object();
13+
```
14+
15+
发现主要就两个变量:
16+
17+
- `map` :用于存放最终数据的。
18+
- `PRESENT` :是所有写入 map 的 `value` 值。
19+
20+
## 构造函数
21+
22+
## add
23+
24+
## get
25+

0 commit comments

Comments
 (0)