We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eefee5c commit 1f4f6d6Copy full SHA for 1f4f6d6
MD/collection/HashSet.md
@@ -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