|
Collections Framework API Change Summary
|
We received hundreds of excellent suggestions concerning previous
releases of the collections framework. Suggestions came from companies,
universities, and individuals all around the world. We're truly thankful for
these suggestions, and we've incorporated many of them. This page summarizes
the differences between the Beta4 and FCS releases, along with a brief
rationale for each change.
Their are very few changes in this release, only one of which has the
potential to cause compatibity problems (the change to
ListIterator.add semantics).
ListIterator Interface
- Modified add semantics.
Previously, the newly added element was inserted after the cursor; now it's
inserted before the cursor. In general, people do not want to see the element
they added as the iteration continues, so they were forced to follow every
call to ListIterator.add with an (extra) call to
ListIterator.next. Worse, repeated calls to
ListIterator.add caused the new elements to stack up backwards unless
the caller threw in a call to next after each call to add. These calls to
next after each insert are no longer necessary. In effect they're now done
automatically.
AbstractList Implementation
-
Added protected removeRange
method, and modified the clear method to rely on the new
method. Overriding this method can significantly improve the
performance of list.subList(i, j).clear(). In the case of
ArrayList and Vector, the performance used to be quadratic,
and now it's linear with a very small constant factor. The good performance
applies to subLists of subLists (ad infinitum) as well.
Array Operations
-
Added
range versions
of the sort
calls. These calls are useful in conjunction with array-based data
structures where only a parts of the array is "active" at any given time.