Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6392565
Votes 0
Synopsis (coll) LinkedHashMap should contain single boolean constructor
Category java:classes_util
Reported Against
Release Fixed
State 5-Cause Known, request for enhancement
Priority: 4-Low
Related Bugs
Submit Date 01-MAR-2006
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
Work Around
N/A
Evaluation
Java does not have keyword parameters; would be nice.
We have these "telescoping constructor" issues in other classes as well.
Posted Date : 2006-03-01 19:58:33.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang