-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
1.4.2
Name: rmT116609 Date: 07/22/2003
A DESCRIPTION OF THE REQUEST :
for ArrayList, removing elements from index n to index m requires now a loop with multiple invocations of remove(idx). This is probably quite inefficient as the backing store is compacted multiple times instead of one. the
removeRange(int from, int to) method is much more efficient, but for some reason is protected. Make it public, or provide a public one that invokes it.
JUSTIFICATION :
improve performance and reduce possibility of user bugs (the loop in the user logic must keep track of the fact that the elements are shifting...)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
an increase in performance with respect to a loop using remove(int idx).
CUSTOMER SUBMITTED WORKAROUND :
right now the user can do the trick as follows:
class MyArrayList extends ArrayList {
public void removeRange(int from, int to) {
super.removeRange(from, to);
}
}
and use MyArrayList instead of ArrayList.
(Incident Review ID: 192315)
======================================================================
- relates to
-
JDK-6303624 (coll) please add subList/clear example to doc of protected method AbstractList.removeRange
- Open