/*
 * The contents of this file are subject to the terms of the Common Development
 * and Distribution License (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the License at http://www.opensource.org/licenses/cddl1.php
 * or http://www.opensource.org/licenses/cddl1.txt.
 *
 * When distributing Covered Code, include this CDDL Header Notice in each file
 * and include the License file at http://www.opensource.org/licenses/cddl1.php.
 * If applicable, add the following below the CDDL Header, with the fields
 * enclosed by brackets [] replaced by your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * The Initial Developer of the Original Software is 
 * Alexander Muthmann <amuthmann at dev-eth0.de>.
 */
package de.dev.eth0.cache;

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

/**
 * This Method implements a Least Recently Used Cache (LRU) with a fixed maximum
 * size. If a new Item is added beyond that capacity, the oldest entry is deleted.
 * The maximum size can be configured by setting the constructor parameter.
 * @author Alexander Muthmann <amuthmann at dev-eth0.de>
 * @version 09/2010
 */
public class LRUCache<K, V> {
    
    private int maxSize;

    public LRUCache(int _maxSize) {
        this.maxSize = _maxSize;
    }

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

