We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e518cb0 commit 54cb082Copy full SHA for 54cb082
MD/collection/LinkedHashMap.md
@@ -238,10 +238,24 @@ LinkedHashMap 的 `get()` 方法也重写了:
238
if (e == null)
239
return null;
240
241
- //多了一个判断是否是按照访问顺序排序,是则将当前的 Entry 移动到链表末尾
+ //多了一个判断是否是按照访问顺序排序,是则将当前的 Entry 移动到链表头部。
242
e.recordAccess(this);
243
return e.value;
244
}
245
+
246
+ void recordAccess(HashMap<K,V> m) {
247
+ LinkedHashMap<K,V> lm = (LinkedHashMap<K,V>)m;
248
+ if (lm.accessOrder) {
249
+ lm.modCount++;
250
251
+ //删除
252
+ remove();
253
+ //添加到头部
254
+ addBefore(lm.header);
255
+ }
256
257
258
259
```
260
261
`clear()` 清空就要比较简单了:
0 commit comments