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


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.

Reply via email to