at.tuwien.ifs.somtoolbox.util
Class LeastRecentelyUsedImageCache
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<java.lang.String,java.awt.image.BufferedImage>
at.tuwien.ifs.somtoolbox.util.LeastRecentelyUsedImageCache
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.awt.image.BufferedImage>
public final class LeastRecentelyUsedImageCache
- extends java.util.LinkedHashMap<java.lang.String,java.awt.image.BufferedImage>
A least-recently-used LRU cache, based on LinkedHashMap
. This cache can hold a fixed a number of
BufferedImage
elements, until the specified memory limit is reached. If a new element is added, and the cache
is full, the least recently used entry is removed.
- Version:
- $Id: LeastRecentelyUsedImageCache.java 4156 2011-02-11 15:56:51Z mayer $
- Author:
- Rudolf Mayer
- See Also:
- Serialized Form
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Methods inherited from class java.util.LinkedHashMap |
clear, containsValue, get |
Methods inherited from class java.util.HashMap |
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
maxCacheSize
private long maxCacheSize
maxCacheSizeReadable
private java.lang.String maxCacheSizeReadable
LeastRecentelyUsedImageCache
public LeastRecentelyUsedImageCache(int maxCacheSizeInMBit)
LeastRecentelyUsedImageCache
public LeastRecentelyUsedImageCache(long maxCacheSize)
removeEldestEntry
protected boolean removeEldestEntry(java.util.Map.Entry<java.lang.String,java.awt.image.BufferedImage> eldest)
- Overrides:
removeEldestEntry
in class java.util.LinkedHashMap<java.lang.String,java.awt.image.BufferedImage>
getMaxCacheSize
public long getMaxCacheSize()
- Returns:
- Returns the maxCacheSize.
getMaxCacheSizeInMBit
public long getMaxCacheSizeInMBit()
setMaxCacheSize
public void setMaxCacheSize(long maxCacheSize)
- Parameters:
maxCacheSize
- The maxCacheSize to set.
setMaxCacheSizeInMBit
public void setMaxCacheSizeInMBit(int maxCacheSizeInMBit)
getCurrentSize
public long getCurrentSize()
- Returns:
- The current size of the cache
getCurrentSizeInMBit
public double getCurrentSizeInMBit()