未验证 提交 5e150b86 编写于 作者: K KayKong 提交者: GitHub

Update 缓存.md

上级 89ff7a1a
......@@ -88,12 +88,14 @@ public class LRU<K, V> implements Iterable<K> {
public void put(K key, V value) {
Node node;
if (map.containsKey(key)) {
Node node = map.get(key);
node = map.get(key);
unlink(node);
}
Node node = new Node(key, value);
if (node == null) {
node = new Node(key, value);
}
map.put(key, node);
appendHead(node);
......@@ -109,6 +111,9 @@ public class LRU<K, V> implements Iterable<K> {
Node next = node.next;
pre.next = next;
next.pre = pre;
node.pre = null;
node.next = null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册