8311517: Adapt ArrayList Javadoc for sequenced collections

Daniel Schmid daniel at wwwmaster.at
Thu Jul 20 15:11:26 UTC 2023


I could create a PR for this if wanted.

I would suggest changing

 > 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.

to

 > The size, isEmpty, get, set, iterator, listIterator, and reversed 
operations run in constant time. The add, addLast, and removeLast 
operations 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.


Is there any other part of the documentation that should be changed?

Note that I do not have an OpenJDK account as I haven't contributed to 
OpenJDK projects before (Though I did sign the OCA).

Yours,
Daniel

Am 20.07.2023 um 17:04 schrieb Daniel Schmid:
>
> I could create a PR for this if wanted.
>
> I would suggest changing
>
> > 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.
>
> to
>
> > The size, isEmpty, get, set, iterator, listIterator, and reversed 
> operations run in constant time. The add, addLast, and removeLast 
> operations 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.
>
>
> Is there any other
>
> ---
> 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/20230720/f7ff9876/attachment-0001.htm>
-------------- 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/20230720/f7ff9876/smime-0001.p7s>


More information about the core-libs-dev mailing list