diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2012-01-14 12:14:40 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2012-01-14 12:14:40 +0100 |
commit | f0db598f7978156a6de8a96bfa316abd76068b41 (patch) | |
tree | 4eebca1671fcea13a66d4ad5101308b6ae574bef /main/src/cgeo/geocaching/utils | |
parent | a0b1d7ba4a23587a4a44cffb7ac80d4d8b336ae9 (diff) | |
download | cgeo-f0db598f7978156a6de8a96bfa316abd76068b41.zip cgeo-f0db598f7978156a6de8a96bfa316abd76068b41.tar.gz cgeo-f0db598f7978156a6de8a96bfa316abd76068b41.tar.bz2 |
refactoring: move and rename LeastRecentlyUsedCache to avoid confusion
Diffstat (limited to 'main/src/cgeo/geocaching/utils')
-rw-r--r-- | main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java b/main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java new file mode 100644 index 0000000..6d18cf5 --- /dev/null +++ b/main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java @@ -0,0 +1,24 @@ +package cgeo.geocaching.utils; + +import java.util.LinkedHashMap; + +/** + * Base class for a caching cache. Don't mix up with a geocache ! + * + * @author blafoo + */ +public class LeastRecentlyUsedCache<K, V> extends LinkedHashMap<K, V> { + + private static final long serialVersionUID = -5077882607489806620L; + private final int maxEntries; + + public LeastRecentlyUsedCache(int maxEntries) { + this.maxEntries = maxEntries; + } + + @Override + protected boolean removeEldestEntry(java.util.Map.Entry<K, V> eldest) { + return size() > maxEntries; + } + +} |