make clear() only clear entries that aren't locked.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@952 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -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;
|
package com.samskivert.util;
|
||||||
|
|
||||||
@@ -21,6 +21,21 @@ public class LockableLRUHashMap extends LRUHashMap
|
|||||||
super(baseMaxSize);
|
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.
|
* Lock the specified key from being removed.
|
||||||
* This has the side effect of increasing the maximum size by 1.
|
* This has the side effect of increasing the maximum size by 1.
|
||||||
|
|||||||
Reference in New Issue
Block a user