[
https://issues.apache.org/jira/browse/COLLECTIONS-240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529387
]
Alan Mehio commented on COLLECTIONS-240:
----------------------------------------
<quoted-statemen>
It would be nice it we can create the correct size for the ArrayList instead of
the default one which is 10
</quoted-statement>
This will not optimize the code since the ArrayList ; please refere to the
below methods in the ArrayList based on
the constructor with empty array size i.e new ArrayList();
public boolean addAll(Collection<? extends E> c) {
Object[] a = c.toArray();
int numNew = a.length;
ensureCapacity(size + numNew); // Increments modCount
System.arraycopy(a, 0, elementData, size, numNew);
size += numNew;
return numNew != 0;
}
public boolean add(E o) {
ensureCapacity(size + 1); // Increments modCount!!
elementData[size++] = o;
return true;
}
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);
}
}
Cheers
Alan Mehio
London, UK
> MultiValueMap should implement Serializable
> -------------------------------------------
>
> Key: COLLECTIONS-240
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-240
> Project: Commons Collections
> Issue Type: Bug
> Components: Map
> Affects Versions: 3.2
> Reporter: Wouter de Vaal
> Assignee: Henri Yandell
> Priority: Minor
> Fix For: 3.3
>
>
> Collection classes should be serializable as they are frequently used in
> model classes which need to be serializable, for example in a HttpSession
> object within a servlet container cluster.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.