Adapt ArrayList Javadoc for sequenced collections

Roger Riggs roger.riggs at oracle.com
Wed Jul 5 15:18:20 UTC 2023


Hi Daniel,

Core-libs-dev is indeed the correct alias for this documentation issue.

Create an issue to track: JDK-8311517 
<https://bugs.openjdk.org/browse/JDK-8311517>

Regards, Roger

On 7/1/23 3:35 PM, Daniel Schmid wrote:

The JEP for sequenced collection (https://openjdk.org/jeps/431) would 
add addFirst(), removeFirst() and reversed() methods to lists.
However, the Javadoc of List mentions:
 > The size, isEmpty, get, set, iterator, and listIterator operations 
run in constant time. The add operation runs in amortized constant time, 
that is, adding n elements requires O(n) time. All of the other 
operations run in linear time (roughly speaking). The constant factor is 
low compared to that for the LinkedList implementation.

This is (at the time of writing) still the case for the jdk21-fork 
(https://github.com/openjdk/jdk21/blob/430ffe7ae691d097de2818391531522f2538431d/src/java.base/share/classes/java/util/ArrayList.java#L42-L47). 


I think this should be updated to include that reversed() runs in 
constant time while addFirst() and removeFirst() run in linear time.

I originally posted this in the core-libs-dev mailing list 
(https://mail.openjdk.org/pipermail/core-libs-dev/2023-June/107328.html) 
but it seems like that mail has been overlooked due to the amount of 
other content with PRs etc. there.

Yours,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20230705/c7a332c3/attachment-0001.htm>


More information about the core-libs-dev mailing list