You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by as...@apache.org on 2002/02/17 00:21:21 UTC
cvs commit: jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru LRUStoreImp.java LRUStore.java LRUElementImp.java LRUElement.java ILRUElement.java
asmuts 02/02/16 15:21:21
Modified: util/src/java/org/apache/commons/util/lru LRUStoreImp.java
LRUStore.java LRUElementImp.java LRUElement.java
ILRUElement.java
Log:
specialized LRUElement in sample implementation
Revision Changes Path
1.2 +18 -0 jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUStoreImp.java
Index: LRUStoreImp.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUStoreImp.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LRUStoreImp.java 16 Feb 2002 23:12:34 -0000 1.1
+++ LRUStoreImp.java 16 Feb 2002 23:21:21 -0000 1.2
@@ -55,6 +55,8 @@
* <http://www.apache.org/>.
*/
+import java.io.Serializable;
+
/**
* Example implementation of LRUStore. Overrides the waterfall method.
*
@@ -83,6 +85,22 @@
{
super( max );
}
+
+
+ /**
+ * Overridden put method. I can control teh wrapper. Created a special
+ * wrapper that records the creation time.
+ * Can get wrapper out from <code>get( key, true );</code>.
+ *
+ *@param key The key
+ *@param val The value
+ */
+ public void put( Serializable key, Serializable val )
+ {
+ ILRUElement le = new LRUElementImp( key, val );
+ update( le );
+ }
+
/**
* Description of the Method
1.2 +8 -10 jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUStore.java
Index: LRUStore.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUStore.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LRUStore.java 16 Feb 2002 23:12:34 -0000 1.1
+++ LRUStore.java 16 Feb 2002 23:21:21 -0000 1.2
@@ -15,12 +15,12 @@
/////////////////////////////////////////////////////
/**
- * Example LRU program with O(1) performance degredation. Partial removal
- * has O(N) performance. A fast reference management system. The least recently
+ * Example LRU program with O(1) performance degredation. Partial removal has
+ * O(N) performance. A fast reference management system. The least recently
* used items move to the end of the list and get waterfalled. Pulled from JCS
- * project. Based on several generic algorithm book examples. Will change
- * into a map interface later. The LRUMemoryCache in JCS will eventually be
- * a wrapper around this.
+ * project. Based on several generic algorithm book examples. Will change into
+ * a map interface later. The LRUMemoryCache in JCS will eventually be a
+ * wrapper around this.
*
*@author asmuts
*@created January 31, 2002
@@ -160,20 +160,18 @@
}
// end update
- // TODO: Implement or modify interface, just implement
- // may need insert if we want to distinguish b/wn put and replace
/**
- * Description of the Method
+ * Should override to create your own wrapper class. You can get the
+ * wrapper out if you want.
*
*@param key Description of the Parameter
*@param val Description of the Parameter
*/
public void put( Serializable key, Serializable val )
{
- LRUElement le = new LRUElement( key, val );
+ ILRUElement le = new LRUElement( key, val );
update( le );
}
-
/**
* Gets an item from the cache.
1.2 +4 -4 jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUElementImp.java
Index: LRUElementImp.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUElementImp.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LRUElementImp.java 16 Feb 2002 23:20:32 -0000 1.1
+++ LRUElementImp.java 16 Feb 2002 23:21:21 -0000 1.2
@@ -34,8 +34,8 @@
/**
* Constructor for the LRUElement object
*
- *@param key Description of the Parameter
- *@param val Description of the Parameter
+ *@param key Description of the Parameter
+ *@param val Description of the Parameter
*/
public LRUElementImp( Serializable key, Serializable val )
{
@@ -50,8 +50,8 @@
/**
* Constructor for the LRUElement object
*
- *@param key Description of the Parameter
- *@param val Description of the Parameter
+ *@param key Description of the Parameter
+ *@param val Description of the Parameter
*/
public LRUElementImp( Serializable key, Object val )
{
1.2 +6 -20 jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUElement.java
Index: LRUElement.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/LRUElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LRUElement.java 16 Feb 2002 23:12:34 -0000 1.1
+++ LRUElement.java 16 Feb 2002 23:21:21 -0000 1.2
@@ -23,25 +23,21 @@
* Description of the Field
*/
public final Serializable val;
- /**
- * Description of the Field
- */
- public final long createTime;
+
//////////////////////////////////////////////////////////////////
/**
* Constructor for the LRUElement object
*
- *@param key Description of the Parameter
- *@param val Description of the Parameter
+ *@param key Description of the Parameter
+ *@param val Description of the Parameter
*/
public LRUElement( Serializable key, Serializable val )
{
this.key = key;
this.val = val;
- // may want to disable this.
- createTime = System.currentTimeMillis();
+
}
@@ -49,8 +45,8 @@
/**
* Constructor for the LRUElement object
*
- *@param key Description of the Parameter
- *@param val Description of the Parameter
+ *@param key Description of the Parameter
+ *@param val Description of the Parameter
*/
public LRUElement( Serializable key, Object val )
{
@@ -82,16 +78,6 @@
}
- //////////////////////////////////////
- /**
- * Gets the createTime attribute of the LRUElement object
- *
- *@return The createTime value
- */
- public long getCreateTime()
- {
- return this.createTime;
- }
///////////////////////////////////////////////////////////
/**
1.2 +2 -10 jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/ILRUElement.java
Index: ILRUElement.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/lru/ILRUElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ILRUElement.java 16 Feb 2002 23:12:34 -0000 1.1
+++ ILRUElement.java 16 Feb 2002 23:21:21 -0000 1.2
@@ -3,9 +3,8 @@
import java.io.Serializable;
/**
- * Allows the element to be overriden and customized.
- *
- * Pulled from JCS project for ease of use.
+ * Allows the element to be overriden and customized. Pulled from JCS project
+ * for ease of use.
*
*@author asmuts
*@created January 15, 2002
@@ -27,12 +26,5 @@
*/
public Serializable getVal();
-
- /**
- * Gets the createTime attribute of the ILRUElement object
- *
- *@return The createTime value
- */
- public long getCreateTime();
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>