|
Description
|
A DESCRIPTION OF THE REQUEST :
It is a little unwieldy to have to call new LinkedHashMap(16, 0.75f, access_order) in order to set the access order. Most developers don't care about the initial capacity or load factor and want to use the defaults.
JUSTIFICATION :
Developers don't have to go to the javadoc to figure out what reasonable defaults are.
---------- BEGIN SOURCE ----------
public class LRUMap<K,V> extends java.util.LinkedHashMap {
int maxsize = 60;
/** Creates a new <code>LRUMap</code> instance.
* @param access_order if false then order is strictly by insertion
* order, <code>get()</code> calls don't change anything */
public LRUMap(boolean access_order, int maxsize) {
//defaults taken from source for HashMap
super(16, 0.75f, access_order); //<-- messy code
this.maxsize = maxsize;
}
protected boolean removeEldestEntry(Map.Entry<K,V> eldest){
return size() > maxsize;
}
}
---------- END SOURCE ----------
Posted Date : 2006-03-01 19:08:35.0
|