|
JTemporal Home Tutorial |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.jtemporal.util.LightLRUCache<K,V>
K - the type of the keyV - the type of the valuepublic class LightLRUCache<K,V>
A lightweight fast LRU cache, based on a HashMap and a linked list.
Reading a value, updates the LRU order.
This class is NOT thread-safe.
Note the the performance is directly dependent on the proformance of the
hashcode() implementation of your key objects.
| Constructor Summary | |
|---|---|
LightLRUCache(int size)
Creates a new LRU cache, of the given size. |
|
LightLRUCache(int size,
float loadFactor)
Creates a new LRU cache, of the given size, whose internal HashMap has the given load factor |
|
| Method Summary | |
|---|---|
void |
clear()
Empties the cache. |
int |
currentSize()
The number of entries currently in the cache. |
V |
get(java.lang.Object key)
Retrieves an entry. |
int |
maxSize()
The maximum number of entries. |
V |
put(K key,
V value)
Adds an new entry to this cache. |
V |
remove(java.lang.Object key)
Removes an entry. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LightLRUCache(int size)
size - the maximum number of entries kept in this cache
public LightLRUCache(int size,
float loadFactor)
size - the maximum number of entries kept in this cacheloadFactor - as defined in HashMap#.
Default is 0.75, higher saves space, lower is faster.| Method Detail |
|---|
public V put(K key,
V value)
key - value -
public V get(java.lang.Object key)
key -
public V remove(java.lang.Object key)
key -
public void clear()
public int currentSize()
public int maxSize()
public java.lang.String toString()
toString in class java.lang.Object
|
JTemporal Home Tutorial |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||