lv.semti.morphology.analyzer.Cache Maven / Gradle / Ivy
/*******************************************************************************
* Copyright 2013,2014 Institute of Mathematics and Computer Science, University of Latvia
* Author: Pēteris Paikens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*******************************************************************************/
package lv.semti.morphology.analyzer;
import java.util.Map;
import java.util.LinkedHashMap;
public class Cache extends LinkedHashMap {
private static final long serialVersionUID = -6922479578059244274L;
private int maxSize = 100000;
public Cache(){
super(10, 0.75f, true);
}
public Cache(int maxSize){
super(10, 0.75f, true);
this.maxSize = maxSize;
}
public void setSize(int maxSize) {
this.maxSize = maxSize;
}
protected boolean removeEldestEntry(final Map.Entry eldest) {
return size() > maxSize;
}
}