You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/01/06 19:34:40 UTC
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections LRUCache.java
remm 2003/01/06 10:34:40
Modified: util/java/org/apache/tomcat/util/collections LRUCache.java
Log:
- Minor update to LRUCache.
Revision Changes Path
1.3 +18 -6 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/LRUCache.java
Index: LRUCache.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/LRUCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LRUCache.java 31 Dec 2001 18:20:04 -0000 1.2
+++ LRUCache.java 6 Jan 2003 18:34:40 -0000 1.3
@@ -88,12 +88,11 @@
{
currentSize = 0;
cacheSize = i;
+ nodes = new Hashtable(i);
}
public Object get(Object key)
{
- if(nodes == null)
- return null;
CacheNode node = (CacheNode)nodes.get(key);
if(node != null)
{
@@ -108,8 +107,6 @@
public void put(Object key, Object value)
{
- if(nodes == null)
- nodes = new Hashtable(cacheSize);
CacheNode node = (CacheNode)nodes.get(key);
if(node == null)
{
@@ -131,10 +128,25 @@
nodes.put(key, node);
}
+ public Object remove(Object key) {
+ CacheNode node = (CacheNode)nodes.get(key);
+ if (node != null) {
+ if (node.prev != null) {
+ node.prev.next = node.next;
+ }
+ if (node.next != null) {
+ node.next.prev = node.prev;
+ }
+ if (last == node)
+ last = node.prev;
+ if (first == node)
+ first = node.next;
+ }
+ return node;
+ }
+
public void clear()
{
- if(nodes != null)
- nodes.clear();
first = null;
last = null;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>