auto commit

This commit is contained in:
CyC2018
2018-09-14 21:35:10 +08:00
parent 8a9b8b15ae
commit 60ed4f498c
6 changed files with 32 additions and 19 deletions

View File

@ -99,7 +99,7 @@ public class LRU<K, V> implements Iterable<K> {
if (map.size() > maxSize) {
Node toRemove = removeTail();
map.remove(toRemove);
map.remove(toRemove.k);
}
}
@ -114,6 +114,7 @@ public class LRU<K, V> implements Iterable<K> {
private void appendHead(Node node) {
node.next = head.next;
node.next.pre = node;
node.pre = head;
head.next = node;
}
@ -122,6 +123,7 @@ public class LRU<K, V> implements Iterable<K> {
private Node removeTail() {
Node node = tail.pre;
tail.pre = node.pre;
node.pre.next = tail;
return node;
}