aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/Cache.java
blob: fd94d1f29c080b01e29dc19d50fd1055a327cb7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package cgeo.geocaching;

import java.util.LinkedHashMap;

/**
 * Base class for a caching cache. Don't mix up with a geocache !
 * 
 * @author blafoo
 */
public class Cache<K, V> extends LinkedHashMap<K, V> {

    private static final long serialVersionUID = -5077882607489806620L;
    private final int maxEntries;

    public Cache(int maxEntries) {
        this.maxEntries = maxEntries;
    }

    @Override
    protected boolean removeEldestEntry(java.util.Map.Entry<K, V> eldest) {
        return size() > maxEntries;
    }

}