|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.util.cache.CacheList
public class CacheList
This is a LRU, Least Recently Used, list that will store a limited number of objects. When there is an attempt to store an object into this list when the list is full then the Least Recently Used objects are removed from the list, In fact this will remove twenty percent of the Least Recently Used objects, this will ensure that there is not a removal of an object for each insert into the list, this may or may not increase the performance.
Constructor Summary | |
---|---|
CacheList()
This will create an list with a maximum allowed number of objects to be inserted into the list. |
|
CacheList(int maxSize)
This will create an list with a maximum allowed number of objects to be inserted into the list. |
Method Summary | |
---|---|
int |
capacity()
This is used to that the capacity of the list can be determined. |
void |
clear()
This is a simple method that will purge all entrys from this list. |
boolean |
contains(java.lang.Object key)
This method will search the list to see if there is an object stored in the list under that name. |
void |
insert(java.lang.Object key,
java.lang.Object obj)
This uses a doubly linked list to store the object within this list. |
int |
length()
This will simply return the number of items in the list. |
java.lang.Object |
lookup(java.lang.Object key)
This method will search to see if it can find the object stored under the key specified and return it. |
java.lang.Object |
remove(java.lang.Object key)
This method will search the list to see if there is an object stored in the list under that name. |
void |
resize(int maxSize)
This simply specifies the maximum size that this list can grow and then purges the Least Recently Used items in the list, that is items at the tail. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CacheList()
public CacheList(int maxSize)
maxSize
- the maximum allowed number of objectsMethod Detail |
---|
public void insert(java.lang.Object key, java.lang.Object obj)
CacheList
. Should not use a duplicate key
in the list.
key
- a unique key, that is not used by any other objectobj
- the object that is being stored in the listpublic boolean contains(java.lang.Object key)
key
- the reference to the list object
public java.lang.Object lookup(java.lang.Object key)
key
- the reference to the stored object
public java.lang.Object remove(java.lang.Object key)
key
- the reference to the list objectpublic void resize(int maxSize)
maxSize
- the max size allowed for the listpublic int length()
public int capacity()
public void clear()
HashMap
and sets the item count
to zero. The garbage collector can collect all objects
that were previously referenced by this list.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |