From 10dd6776120cf6aea35aee8dc73619d9ae1f3a83 Mon Sep 17 00:00:00 2001 From: milley Date: Tue, 22 Jan 2019 23:49:47 +0800 Subject: [PATCH] fixed lru array delete cache --- .gitignore | 1 + java/06_linkedlist/LRUBasedArray.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ff477177..d9da139a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ *.tar.gz *.rar *.DS_Store +*.exe # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* diff --git a/java/06_linkedlist/LRUBasedArray.java b/java/06_linkedlist/LRUBasedArray.java index 160a8926..37436f7b 100644 --- a/java/06_linkedlist/LRUBasedArray.java +++ b/java/06_linkedlist/LRUBasedArray.java @@ -81,7 +81,8 @@ public void cache(T object, int end) { * @param object */ public void removeAndCache(T object) { - value[--count] = null; + T key = value[--count]; + holder.remove(key); cache(object, count); }