RFR: 8311517: Add performance information to ArrayList javadoc [v2]
Brian Burkhalter
bpb at openjdk.org
Fri Aug 4 15:34:32 UTC 2023
On Thu, 27 Jul 2023 06:31:06 GMT, dan1st <duke at openjdk.org> wrote:
>> The [JEP for sequenced collections](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 PR updates that Javadoc to factor in the new methods introduced by JEP 431.
>>
>> https://bugs.openjdk.org/browse/JDK-8311517
>> https://mail.openjdk.org/pipermail/core-libs-dev/2023-June/107328.html
>> https://mail.openjdk.org/pipermail/core-libs-dev/2023-July/109637.html
>>
>> This PR only affects documentation.
>
> dan1st has updated the pull request incrementally with one additional commit since the last revision:
>
> 8311517: ArrayList Javadoc of getFirst/getLast/removeLast
>
> as requested by https://github.com/openjdk/jdk/pull/15040#issuecomment-1652555426
src/java.base/share/classes/java/util/ArrayList.java line 46:
> 44: * {@code listIterator}, and {@code reversed} operations run in constant time.
> 45: * The {@code add}, and {@code addLast} operations runs in <i>amortized
> 46: * constant time</i>, that is, adding n elements requires O(n) time. All of
Should `n` and `O(n)` here be in italics or code font?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15040#discussion_r1284569426
More information about the core-libs-dev
mailing list