|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.aitools.programd.util.LRUCache<K,V>
K - the keyV - the valuepublic class LRUCache<K,V>
Fixed length cache with a LRU replacement policy. If cache items implement CacheListener, they will be informed when they're removed from the cache.
Null keys are not allowed. LRUCache is synchronized.
| Nested Class Summary | |
|---|---|
static interface |
LRUCache.Entry<K_,V_>
Interface for entry iterator; |
| Field Summary | |
|---|---|
protected org.aitools.programd.util.LRUCache.CacheItem<K,V>[] |
_entries
|
| Constructor Summary | |
|---|---|
LRUCache(int initialCapacity)
Create the LRU cache with a specific capacity. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears the cache |
V |
get(K key)
Get an item from the cache and make it most recently used. |
long |
getHitCount()
|
long |
getMissCount()
|
Iterator<LRUCache.Entry<K,V>> |
iterator()
|
Iterator<K> |
keys()
|
Iterator<K> |
keys(Iterator<K> oldIter)
|
V |
put(K key,
V value)
Puts a new item in the cache. |
V |
putIfNew(K key,
V value)
Puts a new item in the cache. |
V |
remove(K key)
Removes an item from the cache |
boolean |
removeTail()
|
int |
size()
|
Iterator<V> |
values()
|
Iterator<V> |
values(Iterator<V> oldIter)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.aitools.programd.util.LRUCache.CacheItem<K,V>[] _entries
| Constructor Detail |
|---|
public LRUCache(int initialCapacity)
initialCapacity - minimum capacity of the cache| Method Detail |
|---|
public int size()
public void clear()
public V get(K key)
key - key to lookup the item
public V put(K key,
V value)
key - key to store datavalue - value to be stored
public V putIfNew(K key,
V value)
key - key to store datavalue - value to be stored
public boolean removeTail()
public V remove(K key)
key - the key to remove
public Iterator<K> keys()
public Iterator<K> keys(Iterator<K> oldIter)
oldIter - the old iterator to use
public Iterator<V> values()
public Iterator<V> values(Iterator<V> oldIter)
oldIter - the old iterator
public Iterator<LRUCache.Entry<K,V>> iterator()
public long getHitCount()
public long getMissCount()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||