You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Yandell (JIRA)" <ji...@apache.org> on 2008/11/03 17:37:44 UTC
[jira] Closed: (COLLECTIONS-302) CollectionUtils.subtract() should
not use ArrayList to improve speed
[ https://issues.apache.org/jira/browse/COLLECTIONS-302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell closed COLLECTIONS-302.
-------------------------------------
Resolution: Won't Fix
No worries - closing the issue as there's nothing major here to work on.
> CollectionUtils.subtract() should not use ArrayList to improve speed
> --------------------------------------------------------------------
>
> Key: COLLECTIONS-302
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-302
> Project: Commons Collections
> Issue Type: Improvement
> Components: Collection
> Reporter: Joachim Rudolph
> Priority: Minor
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> The implementation of version 3.2.1 is
> public static Collection subtract(final Collection a, final Collection b) {
> ArrayList list = new ArrayList( a );
> for (Iterator it = b.iterator(); it.hasNext();) {
> list.remove(it.next());
> }
> return list;
> }
> when a and b are large and similar the subtract implementation will call ArrayList.remove() frequently which copies a potentially large part of the list using system.arraycopy.
> Suggestion : use LinkedList ( at least for large lists )
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.