From 809df481c1a4f58cb8e0446f572b7e4327e5dd09 Mon Sep 17 00:00:00 2001 From: mdb Date: Fri, 5 Aug 2005 02:45:45 +0000 Subject: [PATCH] We need to notify all values about removal when we clear the table. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1686 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/LRUHashMap.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/projects/samskivert/src/java/com/samskivert/util/LRUHashMap.java b/projects/samskivert/src/java/com/samskivert/util/LRUHashMap.java index 5747fcbe..361b265d 100644 --- a/projects/samskivert/src/java/com/samskivert/util/LRUHashMap.java +++ b/projects/samskivert/src/java/com/samskivert/util/LRUHashMap.java @@ -254,6 +254,15 @@ public class LRUHashMap implements Map // documentation inherited from interface public void clear () { + // notify all values of their removal + for (Iterator iter = _delegate.values().iterator(); iter.hasNext(); ) { + Object value = iter.next(); + if (value instanceof LRUItem) { + ((LRUItem)value).removedFromMap(this); + } + } + + // then clear everything out _delegate.clear(); _size = 0; }