diff --git a/projects/samskivert/src/java/com/samskivert/util/LockableLRUHashMap.java b/projects/samskivert/src/java/com/samskivert/util/LockableLRUHashMap.java index 57395606..59df46c8 100644 --- a/projects/samskivert/src/java/com/samskivert/util/LockableLRUHashMap.java +++ b/projects/samskivert/src/java/com/samskivert/util/LockableLRUHashMap.java @@ -1,5 +1,5 @@ // -// $Id: LockableLRUHashMap.java,v 1.1 2002/11/15 01:50:46 ray Exp $ +// $Id: LockableLRUHashMap.java,v 1.2 2002/11/26 21:14:36 ray Exp $ package com.samskivert.util; @@ -21,6 +21,21 @@ public class LockableLRUHashMap extends LRUHashMap super(baseMaxSize); } + /** + * Clear all entries but those that are currently locked. + */ + public void clear () + { + // unfortunately there's not a better way to do this because all the + // appropriate variables have package access + Object[] keys = keySet().toArray(); + for (int ii=0, nn=keys.length; ii < nn; ii++) { + if (! _locks.contains(keys[ii])) { + remove(keys[ii]); + } + } + } + /** * Lock the specified key from being removed. * This has the side effect of increasing the maximum size by 1.