Issue Details (XML | Word | Printable)

Key: COLLECTIONS-302
Type: Improvement Improvement
Status: Closed Closed
Resolution: Won't Fix
Priority: Minor Minor
Assignee: Unassigned
Reporter: Joachim Rudolph
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Collections

CollectionUtils.subtract() should not use ArrayList to improve speed

Created: 13/Aug/08 11:00 AM   Updated: 03/Nov/08 04:36 PM
Return to search
Component/s: Collection
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Original Estimate: 2h
Original Estimate - 2h
Remaining Estimate: 2h
Remaining Estimate - 2h
Time Spent: Not Specified
Remaining Estimate - 2h

Resolution Date: 03/Nov/08 04:36 PM


 Description  « Hide
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 )



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.