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 e0a49ad commit adc99f0Copy full SHA for adc99f0
MD/collection/LinkedHashMap.md
@@ -244,4 +244,19 @@ LinkedHashMap 的 `get()` 方法也重写了:
244
}
245
```
246
247
+`clear()` 清空就要比较简单了:
248
+
249
+```java
250
+ //只需要把指针都指向自己即可,原本那些 Entry 没有引用之后就会被 JVM 自动回收。
251
+ public void clear() {
252
+ super.clear();
253
+ header.before = header.after = header;
254
+ }
255
+```
256
257
258
+## 总结
259
260
+总的来说 `LinkedHashMap` 其实就是对 `HashMap` 进行了拓展,使用了双向链表来保证了顺序性。
261
262
0 commit comments