view artifacts-common/src/main/java/de/intevation/artifacts/common/utils/LRUCache.java @ 341:e0efa2c28d19

Helper function to create a document to remove an artifact from an collection. artifacts/trunk@2958 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 13 Oct 2011 12:19:43 +0000
parents 9dbeb88006e9
children c40729bfe06d
line wrap: on
line source
package de.intevation.artifacts.common.utils;

import java.util.Map;
import java.util.LinkedHashMap;

public class LRUCache<K, V>
extends      LinkedHashMap<K, V> 
{
    public static final int DEFAULT_MAX_CAPACITY = 25;

    private int maxCapacity;

    public LRUCache() {
        this(DEFAULT_MAX_CAPACITY);
    }

    public LRUCache(int maxCapacity) {
        this.maxCapacity = maxCapacity;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
        return size() > maxCapacity;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org