[ http://jira.andromda.org/browse/JAVA-14?page=comments#action_11612 ]
Alex Radzivanovich commented on JAVA-14:
----------------------------------------
I think it is only enough to specify initial capacity. It seems like ArrayList
doesn't have the notion of load-factor.
Let's look at sources:
public ArrayList(int initialCapacity) {
super();
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal Capacity: "+
initialCapacity);
this.elementData = (E[])new Object[initialCapacity];
}
public boolean add(E o) {
ensureCapacity(size + 1); // Increments modCount!!
elementData[size++] = o;
return true;
}
/**
* Increases the capacity of this <tt>ArrayList</tt> instance, if
* necessary, to ensure that it can hold at least the number of elements
* specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity.
*/
public void ensureCapacity(int minCapacity) {
modCount++;
int oldCapacity = elementData.length;
if (minCapacity > oldCapacity) {
Object oldData[] = elementData;
int newCapacity = (oldCapacity * 3)/2 + 1;
if (newCapacity < minCapacity)
newCapacity = minCapacity;
elementData = (E[])new Object[newCapacity];
System.arraycopy(oldData, 0, elementData, 0, size);
}
}
> 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