[ http://jira.andromda.org/browse/JAVA-14?page=comments#action_11613 ] Alex Radzivanovich commented on JAVA-14: ----------------------------------------
Pardon me, typed without thinking :( Certainly both initial capacity and load factor must be specified for hash map. * <p>An instance of <tt>HashMap</tt> has two parameters that affect its * performance: <i>initial capacity</i> and <i>load factor</i>. The * <i>capacity</i> is the number of buckets in the hash table, and the initial * capacity is simply the capacity at the time the hash table is created. The * <i>load factor</i> is a measure of how full the hash table is allowed to * get before its capacity is automatically increased. When the number of * entries in the hash table exceeds the product of the load factor and the * current capacity, the capacity is roughly doubled by calling the * <tt>rehash</tt> method. * * <p>As a general rule, the default load factor (.75) offers a good tradeoff * between time and space costs. Higher values decrease the space overhead * but increase the lookup cost (reflected in most of the operations of the * <tt>HashMap</tt> class, including <tt>get</tt> and <tt>put</tt>). The * expected number of entries in the map and its load factor should be taken * into account when setting its initial capacity, so as to minimize the * number of <tt>rehash</tt> operations. If the initial capacity is greater * than the maximum number of entries divided by the load factor, no * <tt>rehash</tt> operations will ever occur. I hope I got it right this time. So the if a enumeration has three literals the best code for it would be: private static final java.util.Map values = new java.util.HashMap(3, 1.0f); private static java.util.List literals = new java.util.ArrayList(3); private static java.util.List names = new java.util.ArrayList(3); > Generated enumeration classes must specify sizes of internal collections > ------------------------------------------------------------------------ > > Key: JAVA-14 > URL: http://jira.andromda.org/browse/JAVA-14 > Project: Java Cartridge > Type: Improvement > Reporter: Alex Radzivanovich > Assignee: Wouter Zoons > Priority: Minor > > Enumeration template generates code like this: > private static final java.util.Map values = new java.util.HashMap(); > private static java.util.List literals = new java.util.ArrayList(); > private static java.util.List names = new java.util.ArrayList(); > I think if I had an enumeration of three literals the following code would be > better: > private static final java.util.Map values = new java.util.HashMap(3); > private static java.util.List literals = new java.util.ArrayList(3); > private static java.util.List names = new java.util.ArrayList(3); -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.andromda.org/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 _______________________________________________ Andromda-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/andromda-devel
