lrucache.java
来自「jgap3.2 遗传算法工具包,嘿嘿,笨鸟先飞哦」· Java 代码 · 共 23 行
JAVA
23 行
package org.jgap.util;
import java.util.*;
public class LRUCache extends LinkedHashMap {
// Create cache
private int m_maxEntries;
public LRUCache(int a_maxExtries) {
super(a_maxExtries+1, 0.75F, true);
m_maxEntries = a_maxExtries;
}
// This method is called just after a new entry has been added
public boolean removeEldestEntry(Map.Entry eldest) {
return size() > m_maxEntries;
}
// If the cache is to be used by multiple threads,
// the cache must be wrapped with code to synchronize the methods
// cache = (Map) Collections.synchronizedMap(cache);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?