Adapt ArrayList Javadoc for sequenced collections

Daniel Schmid daniel at wwwmaster.at
Sat Jun 10 12:10:46 UTC 2023


Dear members of the core-libs-dev mailing list,

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.

Yours,
Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4490 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20230610/cb9dcda7/smime-0001.p7s>


More information about the core-libs-dev mailing list