org.codehaus.jackson.map.util.LRUMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-mapper-asl Show documentation
Show all versions of jackson-mapper-asl Show documentation
Data Mapper package is a high-performance data binding package
built on Jackson JSON processor
The newest version!
package org.codehaus.jackson.map.util;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Helper for simple bounded LRU maps used for reusing lookup values.
*
* @since 1.7
*/
@SuppressWarnings("serial")
public class LRUMap extends LinkedHashMap
{
protected final int _maxEntries;
public LRUMap(int initialEntries, int maxEntries)
{
super(initialEntries, 0.8f, true);
_maxEntries = maxEntries;
}
@Override
protected boolean removeEldestEntry(Map.Entry eldest)
{
return size() > _maxEntries;
}
}