|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
org.mmbase.util.LRUHashtable
A hashtable which has a maximum of entries. Old entries are removed when the maximum is reached. This table is used mostly to implement a simple caching system.
Cache,
Serialized Form| Nested Class Summary | |
class |
LRUHashtable.LRUEntry
Element used to store information from the LRUHashtable. |
protected class |
LRUHashtable.LRUEntrySet
Used by 'entrySet' implementation, to make the Map modifiable. |
protected class |
LRUHashtable.LRUEntrySetIterator
Used by 'entrySet' implementation, to make the Map modifiable. |
| Nested classes inherited from class java.util.Map |
Map.Entry |
| Constructor Summary | |
LRUHashtable()
Creates the URL Hashtable with maximum capacity 100, starting capacity 101, and growing capacity 0.75. |
|
LRUHashtable(int size)
Creates the URL Hashtable with starting capacity 101 and growing capacity 0.75. |
|
LRUHashtable(int size,
int cap)
Creates the URL Hashtable with growing capacity 0.75. |
|
LRUHashtable(int size,
int cap,
float lf)
Creates the URL Hashtable. |
|
| Method Summary | |
void |
clear()
Clears the table. |
Object |
clone()
NOT IMPLEMENTED |
void |
config(Map map)
Configure the implementation with the given configuration values |
Enumeration |
elements()
Returns an Enumeration on the table's element values. |
Set |
entrySet()
Returns the entries of this Map. |
Object |
get(Object key)
Retrieves an element from the table. |
int |
getByteSize()
Determines the byte-size of this object |
int |
getByteSize(SizeOf sizeof)
Determines the byte-size of this object using the given SizeOf instance. |
int |
getCount(Object key)
Retrieves the count of the object with a certain key. |
Enumeration |
getOrderedElements()
Deprecated. use getOrderedEntries |
Enumeration |
getOrderedElements(int maxnumber)
Deprecated. use getOrderedEntries |
List |
getOrderedEntries()
Returns an ordered list of Map.Entry's. |
List |
getOrderedEntries(int maxNumber)
Returns an ordered list of Map.Entry's. |
Set |
keySet()
You should only remove entries from LRUHashtable using the 'remove' function, or using the iterator of entrySet() otherwise the linked list gets messed up. |
static void |
main(String[] argv)
|
int |
maxSize()
Return the maximum size of the table |
Object |
put(Object key,
Object value)
Store an element in the table. |
Object |
remove(Object key)
Remove an element from the table. |
void |
setMaxSize(int size)
Change the maximum size of the table. |
int |
size()
Return the current size of the table |
String |
toString()
Returns a description of the table. |
String |
toString(boolean which)
Returns a description of the table. |
Collection |
values()
|
| Methods inherited from class java.util.Hashtable |
contains, containsKey, containsValue, equals, hashCode, isEmpty, keys, putAll, rehash |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
containsKey, containsValue, equals, hashCode, isEmpty, putAll |
| Constructor Detail |
public LRUHashtable(int size,
int cap,
float lf)
size - the maximum capacitycap - the starting capacity (used to improve performance)lf - the amount with which current capacity frows
public LRUHashtable(int size,
int cap)
size - the maximum capacitycap - the starting capacity (used to improve performance)public LRUHashtable(int size)
size - the maximum capacitypublic LRUHashtable()
| Method Detail |
public Object put(Object key,
Object value)
put in interface Mapkey - the key of the elementvalue - the value of the element
null if it could not be foundpublic int getCount(Object key)
getCount in interface CacheImplementationInterfacekey - the key of the element
public Object get(Object key)
get in interface Mapkey - the key of the element
null if it could not be foundpublic Object remove(Object key)
remove in interface Mapkey - the key of the element
null if it could not be foundpublic Set keySet()
keySet in interface Mappublic Set entrySet()
entrySet in interface Mappublic Collection values()
values in interface MapkeySet()public int size()
size in interface Mappublic void setMaxSize(int size)
setMaxSize in interface CacheImplementationInterfacesize - the new desired sizepublic int maxSize()
maxSize in interface CacheImplementationInterfacepublic String toString()
public String toString(boolean which)
which - if true, the stored values are described.
public void clear()
clear in interface Mappublic Object clone()
public Enumeration elements()
Enumeration on the table's element values.
public Enumeration getOrderedElements()
public Enumeration getOrderedElements(int maxnumber)
public List getOrderedEntries()
public List getOrderedEntries(int maxNumber)
public void config(Map map)
CacheImplementationInterface
config in interface CacheImplementationInterfacepublic int getByteSize()
SizeMeasurable
getByteSize in interface SizeMeasurablepublic int getByteSize(SizeOf sizeof)
SizeMeasurable
getByteSize in interface SizeMeasurablepublic static void main(String[] argv)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||