JDK-4266874 : java.util.AbstractSet can speed up removeAll
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 1.2.2
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1999-08-30
  • Updated: 2021-03-03
  • Resolved: 1999-09-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.3.0 kestrelFixed
Related Reports
Relates :  
Description

Name: rlT66838			Date: 08/30/99


This may be related to bug 4152868. I noticed that
TreeSet.removeAll doesn't override this method
inherited from AbstractCollection class. I made my
application about 40% faster by extending TreeSet
and overriding removeAll as follows:

public boolean removeAll(Collection c)
{
	boolean modified = false;
	Iterator i = c.iterator();
	while (i.hasNext())
	{
		modified = remove(i.next());
	}
	return modified;
}

This code takes advantage of RB tree structure
used in the implementation.
(Review ID: 94612) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: kestrel FIXED IN: kestrel INTEGRATED IN: kestrel
14-06-2004

WORK AROUND Name: rlT66838 Date: 08/30/99 Extend TreeSet and override removeAll. ======================================================================
11-06-2004

EVALUATION The suggested solution is probably only faster when c has fewer elements than this collection. However, a removeAll for Sets that checks to see which collection is smaller and iterates over that collection might be faster in the overwhelming majority of cases. michael.mccloskey@eng 1999-08-30
30-08-1999