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 9406221 commit 836ec5fCopy full SHA for 836ec5f
MD/collection/LinkedHashMap.md
@@ -182,4 +182,18 @@
182
}
183
```
184
185
-主体的实现都是借助于 `HashMap` 来完成的,只是对其中的 `recordAccess(),createEntry(), createEntry()` 进行了重写。
+主体的实现都是借助于 `HashMap` 来完成的,只是对其中的 `recordAccess(),createEntry(), createEntry()` 进行了重写。
186
+
187
+`LinkedHashMap` 的实现:
188
189
+```java
190
+ //就是判断是否是根据访问顺序排序,如果是则需要将当前这个 Entry 移动到链表的末尾
191
+ void recordAccess(HashMap<K,V> m) {
192
+ LinkedHashMap<K,V> lm = (LinkedHashMap<K,V>)m;
193
+ if (lm.accessOrder) {
194
+ lm.modCount++;
195
+ remove();
196
+ addBefore(lm.header);
197
+ }
198
199
+```
0 commit comments